My page has a js function to open a new window with window.open. The new window needs to have a bunch of javascript on it, but ie8 refuses to allow it.
With FF and every other browser I can set the innerHTML of the new window to include <script>...</script> tags, or append them using the DOM appendChild method after the new window opens to either the body or the head, no problem. The new window loads fine and all the scripts work.
However, I tried all this in IE8 and I either get a "no such interface is supported" error, or the new window and the calling window both just freeze and I have to kill them with Task Manager.
Is there any way to include <script> tags in a new window with ie8? PLEASE help!
Here's an example of what I'm trying to do:
Code:
function openwindow()
{
var ih=''
ih += '<!doctype html><html><head>'
ih += '<meta charset="UTF-8" />'
ih += '<script type="text/javascript" src="script1.js"></script>'
ih += '<script type="text/javascript" src="script2.js"></script>'
ih += '<script type="text/javascript" src="script3.js"></script>'
ih += '</head>'
ih += '<body>'
ih += '<h1>test</h1>'
ih += 'yay'
ih += '</body>'
ih += '</html>'
mywin = window.open('','','width=500px, height=500px')
mywin.document.open()
mywin.document.writeln(ih)
mywin.document.close()
}
I also tried something like this:
Code:
function openwindow()
{
var ih=''
ih += '<!doctype html><html><head>'
ih += '<meta charset="UTF-8" />'
ih += '</head>'
ih += '<body>'
ih += '<h1>test</h1>'
ih += 'yay'
ih += '</body>'
ih += '</html>'
mywin = window.open('','','width=500px, height=500px')
mywin.document.open()
mywin.document.writeln(ih)
mywin.document.close()
appendscripts(mywin)
}
function appendscripts(mywin)
{
var sarr = ['script1.js', 'script2.js', 'script3.js']
for(var x=0;x<sarr.length;sarr++)
{
var s = document.createElement('script')
s.type='text/javascript'
mywin.document.getElementsByTagName('head')[0].appendChild(s)
mywin.src = sarr[x]
}
}
but that didn't work in ie either.