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);
精彩评论