Click to See Complete Forum and Search --> : New Window from new window


videopoet
01-03-2003, 11:50 PM
Hi

I've been trying to work out a tool for some very inexperienced users to use to generate new pages for a site within a fairly simple format. I'm having trouble with using document.write to create the javascript to open a further new window to show an image. I've as far as this:

<HTML>
<HEAD>

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- hide

function openWin() {
newWin=open("", "displayWindow",
"width=600,height=400,toolbar=yes,menubar=yes,scroll=yes,status=yes");

// open document for further output
newWin.document.open();

// create document
newWin.document.write('<HTML>\n<HEAD>\n<TITLE>New Window 1</TITLE>\n');


// START OF SCRIPT FOR NEW PAGE
newWin.document.writeln('<SCRIPT TYPE="text/javascript"; LANGUAGE="JavaScript">');
newWin.document.writeln('<!-'+'-hide');
newWin.document.writeln('function openWin() {');


newWin.document.writeln('newWin=open("picture.html","displaywindow",width=300,height=300,toolbar=yes,menubar

=yes,scroll=yes)\n');
newWin.document.writeln('}\n\n');
newWin.document.writeln('//'+'-->');
newWin.document.writeln('</SC'+'RIPT>\n');
//END OF SCRIPT FOR NEW PAGE




newWin.document.write('</HEAD>\n<BODY>\n');

newWin.document.write('<TABLE>\n<TR>\n<TD>\n');
newWin.document.write('<A HREF=javascript:onClick="openWin()">window3</A>\n');
newWin.document.write('</TD>\n</TR>\n</TABLE>\n');


newWin.document.write('</BODY>\n</HTML>');

newWin.document.close();
}

//-->

</SCRIPT>


</HEAD>
<BODY>
<FORM>
<INPUT TYPE="button" VALUE="clickme" onClick="openWin()">
</FORM>
</BODY>
</HTML>

I can't for the life of me spot the flaw in the code this generates but the link in the new (2nd) window when clicked just writes *openWin()* in itself rather than opening another new (3rd) window. I would also appreciate knowing if this works in other browsers 'cos I'm doing this at work where all I have is IE6 on win2k.
Thanx
IanI

swon
01-04-2003, 01:20 AM
there were a few faults like <a href=javascriptonClick=... instead of <a href="#" onClick= and a syntax error..

try out this:

<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript">
<!-- hide

function openWin() {
newWin=open("", "displayWindow"," width=600,height=400,toolbar=yes,menubar=yes,scroll=yes,status=yes");

// open document for further output
newWin.document.open();

// create document
newWin.document.write('<HTML>\n<HEAD>\n<TITLE>New Window 1</TITLE>\n');


// START OF SCRIPT FOR NEW PAGE
newWin.document.writeln('<SCRIPT TYPE="text/javascript"; LANGUAGE="JavaScript">');
newWin.document.writeln('<!-'+'-hide');
newWin.document.writeln('function openWin() {');


newWin.document.writeln('newWin=open("picture.html","displaywindow","width=300,height=300,toolbar=yes,menubar=yes,scroll=yes")\n');
newWin.document.writeln('}\n\n');
newWin.document.writeln('//'+'-->');
newWin.document.writeln('</SC'+'RIPT>\n');
//END OF SCRIPT FOR NEW PAGE




newWin.document.write('</HEAD>\n<BODY>\n');

newWin.document.write('<TABLE>\n<TR>\n<TD>\n');
newWin.document.write('<A HREF="#" onClick="openWin()">window3</A>\n');
newWin.document.write('</TD>\n</TR>\n</TABLE>\n');
newWin.document.write('</BODY>\n</HTML>');
newWin.document.close();
}

//-->
</SCRIPT>

videopoet
01-04-2003, 02:01 AM
Hi swon

tried your version, got 'error on page' (1st window). I'm actually finishing work now so it will be a while before I can come back to this - currently not on line at home as moving about. Be back some time in the early hours (GMT) tomorrow.

Thanks all the same.
IanI

swon
01-04-2003, 02:10 AM
The forum breaks the lines, be sure that no document.write line is broken:

winopen.document.write("lkajsdlkasl
kjalklak");

should be:
winopen.document.write("lkajsdlkaslkjalklak");

videopoet
01-04-2003, 05:52 PM
Cheers swon

guess I was getting a little tired last night - many thanks

IanI