I\'m running this function to open a new window.
function htmlNewWindow(id) {
var html = $(id).html();
var newWindow = window.open(\'\');
newWind
Scripts added with .innerHTML
aren't executed. You need to create a script
node and append it to the window's DOM.
$("#button").click(newWindow);
function newWindow(id) {
var html = $(id).html();
var win = window.open('');
win.document.head.innerHTML = 'Hi ';
win.document.body.innerHTML = '' + html + '';
var script = document.createElement('script');
script.src = 'js/myScript.js';
win.document.head.appendChild(script);
}
This doesn't run in Stack Snippet's sandbox, here's a working jsfiddle.