How to add a div to popup window in javascript?

i have created a popup window using the following code in javascript;"", "myWindow", "status = 1, height = 300, width = 300, resizable = 0");

i need to add following dynamic div to that popup window.

 <div><img src="/images/img1.jpg" /></div>

the above div is dynamic because,the image src will vary according to the query string in the url



You can't for security reasons. Due to the same-origin-policy (and is certainly not your domain), you won't be allowed to access the DOM of the other window.

If the popup is from the same domain, the return value of will be a reference to the popup's window object:

var popup ="/relative path.html", ...);
popup.onload = function() { // of course you can use other onload-techniques
    jQuery(popup.document.body).append("<div />"); // or any other dom manipulation

Just use the following code:

a href="" onclick=", null, 'height=580, width=680, toolbar=0, location=0, status=1, scrollbars=1, resizable=1'); return false"


As bergi said no append to DOM from external domain. But for same domain(taken from here)'about:blank','instructions','width=300,height=200');
doc.write('<div id="instructions">instructions</div>');
//reference to the div inside the popup

You can see an example here also.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.