Skip to content Skip to sidebar Skip to footer

Document Object Of Window.open

var theNewWindow = window.open('http://www.example.com', 'example', ''); How can I use the document object of theNewWindow to dynamically update the dom of the new window.

Solution 1:

You can, only if the new page is the same domain or about:blank. For example:

var temp = window.open('about:blank', 'example', '');
var div = temp.document.createElement("div");
div.innerHTML = "Hello!";
temp.document.body.appendChild( div );

And see the working example

Solution 2:

If you have permission to modify the new window (e.g. it's the same origin), then you can get the document via:

theNewWindow.document

Post a Comment for "Document Object Of Window.open"