Skip to content Skip to sidebar Skip to footer

Window.open And Modifying Dom Of New Window

Suppose I open a new window using: newWindow = window.open(newUrl) var ul = newWindow.document.getElementsByTagName('ul')[0]; ul.innerHTML = 'new content'; However, this doesn't m

Solution 1:

It is possible assuming the new window you are opening belongs on the same domain as the opener. If not you cannot modify its DOM for security reasons as you are violating the same origin policy.

Solution 2:

DOM will not be loaded immediately once you open a window. You have to call the method to change the innerHTML on after load of the child window. Or simply you can use the setTimeout to delay the DOM access.

Post a Comment for "Window.open And Modifying Dom Of New Window"