I got a portion of javascript code embedded in HTML (generated on the server side) that looks like this:
function winWriteMail2(){
var win = open(\'\',\'wi
This code worked for me:
function winWriteMail2(){
var win = open('','wininfo', 'width=400,height=300,scrollbars=yes,resizable=yes');
win.document.open();
win.document.write('');
win.document.write('');
win.document.write('this is the body content');
win.document.write('');
win.document.close();
var h = win.document.getElementsByTagName("head")[0];
var js = win.document.createElement("script");
js.type = "text/javascript";
js.src = "js/scriptfile.js";
h.appendChild(js);
}
Here is what I needed to change in your code to make it work:
//From
var js = document.createElement("script");
//To
var js = win.document.createElement("script");
You need to create the script element in the same document that you are appending.