include the same javascript in created code with secondWindow.document.writeln()

E

eels

Hello,

I want to open a new window with javascript:
secondWindow=window.open(...)
secondWindow.document.writeln(...)

I wrote the javascript code into a separate file secondwindow.js.

I need in the new window the same javascript code, therefore:
secondWindow.document.writeln('<script type="text/javascript"
language="javascript1.2" src="../../js/secondwindow.js"><\/script>');

Just this line makes problems in Internet Explorer (without reaction),
not always and not in all Internet Explorer versions.
Netscape, Opera and Mozilla work without problems.

I tested successfully with w3c validator the XHTML code which created
with secondWindow.document.writeln().

What is the reason? How can I resolve this problem?
Thank you for your hints, Eels
 
A

ASM

eels said:
Hello,

I want to open a new window with javascript:
secondWindow=window.open(...)
secondWindow.document.writeln(...)

I wrote the javascript code into a separate file secondwindow.js.

why won't you use mother's JS ?

opener.onefunction(arg1,arg2);
I need in the new window the same javascript code, therefore:
secondWindow.document.writeln('<script type="text/javascript"
language="javascript1.2" src="../../js/secondwindow.js"><\/script>');

try with something as follow :

var myCode = '<html><head><title>new window<\/title>'
myCode += '<script type="text/javascript" language="javascript1.2"'+
'src="../../js/secondwindow.js"><\/script>';
myCode += '<\/head><body>' // and so on ...

with(secondWindow.document) {
open();
write(myCode);
close();
}


If that doesn't solve your IE problems, could try with :
secondwindow.js">'+'<'+'/script>';
insteed of :
secondwindow.js"><\/script>';

'<'+'/head><body>'
insteed :
'<\/head><body>'
 
E

eels

Hello,

the hint
var myCode = '<html><head><title>new window<\/title>'
myCode += '<script type="text/javascript" language="javascript1.2"'+
'src="../../js/secondwindow.js"><\/script>';
myCode += '<\/head><body>' // and so on ...

with(secondWindow.document) {
open();
write(myCode);
close();
}
gives the solution.
Thank you Eeels.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top