开发者

Javascript or Jquery update div in new opened child window - need syntax to update child window div

I have an Ajax function that returns an html string as vReportContent.

Then I open a new html page using javascript window.open

There is a div on this page called 'divReportContent' that I want to update with vReportContent

Here's the javascript/jquery code example:

var vReportCont开发者_如何学Cent = msg; (returned from Jquery Ajax call - this works fine)
var vUrl = 'PrintReport.html';
var vWindowName = 'PrintReport';
window.open('' + vUrl + '', '' + vWindowName + '', width=1010, height=750;

* Update the child (opened) window div with vReportContent

something like: $('#divReportContent').html(vReportContent);

Or a javascript equivalent.

Thanks!


Try this. We have to wait until the document inside the new window is loaded before we try to find the element.

var vReportContent = msg; (returned from Jquery Ajax call - this works fine)
var vUrl = 'PrintReport.html';
var vWindowName = 'PrintReport';
var newWindow = window.open('' + vUrl + '', '' + vWindowName + '', width=1010, height=750;

$(newWindow).load(function(){
   $(newWindow).find('#divReportContent').html(vReportContent);
});


You can try something like this:

var w = window.open(...);
$(w.document).find('#divReportContent').html(vReportContent);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜