How to add script files in child window using javascript?

javascript

Solution

Basically:

var win, doc;

win = window.open('', 'dialog', opts);
doc = win.document;

doc.write(
    "<html><head>"
    + "<script type='text/javascript' src='path/to/your/script.js'></script>"
    + "<script type='text/javascript'>"
    + "/* this is inline script inserted by JavaScript, below is a function converted to it's string representation */"
    + someFuncInVariable.toString()
    + "</script>"
    + "</head><body>"
    + "</body></html>"
);
doc.close();

Problem

How to add script files in child window using javascript? Consider the following code: ``` myWindow = window.open("", "", 'width=650,height=700,menubar=yes,resizable=yes,scrollbars=yes'); myWindow.focus(); myWindow.document.write('<script src="'+App.data.assets_url+'\/javascript\/jquery.js"><\/script>'); ``` Above code doesn't work properly in IE. It shows blank (child) window, but in chrome it works properly. It shows all the content of the child window. In Mozilla it's not working properly too because of above `myWindow.document.write` line browser's print option.

Original source