open window and close window in onLoad

Results 1 to 4 of 4

Thread: open window and close window in onLoad

  1. #1
    Margaret Widholm Guest

    Default open window and close window in onLoad

    Ok, I asked this question in the html forum, but to no response, unfortunately and I&#039m remotely desperate... I&#039m trying to open one window and close the current window in the onload of a page. Here&#039s my code:<BR>In the header:<BR>&#060;script language="JavaScript"&#062;<BR>//&#060;!--<BR>function openWindow(url, name)<BR>{<BR>popupWin =, name, "width=350,height=400,status=no,toolbar=no,menubar =no,left=0,right=0");<BR>}<BR><BR>//--&#062;<BR>&#060;/script&#062;<BR><BR>&#060;script language="javascript"&#062;<BR>setTimeout(" ose();",5000)<BR>&#060;/script&#062;<BR><BR>&#060;body onLoad=",&#039oemain&#039,&#039scrollbars=y es,resizable=yes,width=700,height=700&#039);"&#062 ;<BR><BR>Any help is greatly appreciated- ty!

  2. #2
    John Weeflaar Guest

    Default RE: open window and close window in onLoad

    Try this:<BR>Suppose the current window is first.asp, the second and third<BR>that will be opened: second.asp, third.asp.<BR>Instead of opening third.asp from the onload event of the second.asp, you can open second.asp and third.asp at the same time when you click a button on the first.asp (closing first.asp):<BR>onClick="self.close(); #039second.asp&#039); 39)"<BR>This will work.<BR>And so, when you click the button on the current window, it&#039ll<BR>close it, and open the second and third windows.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: open window and close window in onLoad

    That&#039s a neat trick.<BR> I did some experimenting and found that it worked perfectly with the I.E. browser, but got an error when I tried it with Netscape 4.04.<BR> The error is:<BR> "This program has performed an illegal operation and will be shut down."<BR> The details shows:<BR> "Netscape caused an invalid page fault in Module Kernel32.dll at 0157:bff78ae3"<BR> The two new windows did not open.<BR> Interestingly, if I just opened the two new windows without the self.close() it worked fine(ofcourse the original winfow was still open).<BR> The morale I suppose is that Netscape won&#039t die easily.<BR>

  4. #4
    John Weeflaar Guest

    Default RE: open window and close window in onLoad

    Thanks Bruce.<BR>Apparently, self.close() should be put last to make it work.<BR>I just tried this code, and it works fine in both browsers.<BR>onClick=" #039);;<BR> ose()"<BR>(in one line)<BR>We can also use a function instead of writing it in a line.<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts