admin管理员组文章数量:1426459
im trying to dynamically create elements in the child window based on the values i have in the the parent window but no success.The child window is opening but not with the elements.Here is the code i've written,could some one please have a loot at it ? is this possible at all using javascript/jquery>
function fnOpenPrint(){
openPrint = window.open('print.htm');
childWin = openPrint.document;
var newDiv = childWin.createElement("<div id='para'>")
newDiv.innerHTML = document.forms[0].txtBranch.value;
}
im trying to dynamically create elements in the child window based on the values i have in the the parent window but no success.The child window is opening but not with the elements.Here is the code i've written,could some one please have a loot at it ? is this possible at all using javascript/jquery>
function fnOpenPrint(){
openPrint = window.open('print.htm');
childWin = openPrint.document;
var newDiv = childWin.createElement("<div id='para'>")
newDiv.innerHTML = document.forms[0].txtBranch.value;
}
Share
Improve this question
edited Oct 21, 2010 at 15:40
manraj82
asked Oct 21, 2010 at 15:31
manraj82manraj82
6,34525 gold badges58 silver badges85 bronze badges
2 Answers
Reset to default 3try
function fnOpenPrint(){
var openPrint = window.open('print.htm');
openPrint.onload = function() {
var doc = openPrint.document;
var newDiv = doc.createElement("div");
newDiv.id = 'para';
newDiv.innerHTML = document.forms[0].txtBranch.value;
doc.body.appendChild(newDiv);
};
}
DOM manipulations in the child window must be done after it finishes loading.
createElement doesn't automatically add it to the document... you'd prbably have to do this too:
childWin.body.appendChild(newDiv);
本文标签: javascripthow to dynamically create elements in a child window from a parent windowStack Overflow
版权声明:本文标题:javascript - how to dynamically create elements in a child window from a parent window - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745478844a2660086.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论