How to write JavaScript to a separate window?

Posted by George Edison on Stack Overflow See other posts from Stack Overflow or by George Edison
Published on 2010-04-23T06:36:49Z Indexed on 2010/04/23 6:43 UTC
Read the original article Hit count: 318

Filed under:
|
|
|

I have opened a new window with JavaScript:

var newwin = window.open('','preview','width=600,height=500');

Now I want to write some JavaScript to the window:

newwin.document.write("<script type='text/javascript'>alert('Hi!');<" + "/script>");
newwin.document.close();

However, the script never gets executed. Am I doing something wrong?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about open