Jump to content

Script-troubble


Hepolite

Recommended Posts

I tried that, it didn't work... Maybe I did some mistake when I added some more code.

<script type="text/javascript">function verifyAnswer(){if(confirm("Are you sure?")){	return true;}else{	return false;}}function open_win(){	// only run the window.open code if the verifyAnswer	// function returns true.	if(verifyAnswer())	{var win = window.open("http://page1.html");win.onUnload = function(){  var win2 = window.open("http://page2.html");  win2.onUnload = function()  {	var win3 = window.open("http://page3.html");	win3.onUnload = function()	{	  var win4 = window.open("http://page4.html");	  win4.onUnload = function()	  {		var win5 = window.open("http://page5.html");	  }	}  }}	}}</script><input type="submit" value="Somevalue" name="gwar" onclick="open_win()" />

This works, but it open only one page, and it doesn't close... Nothing happens after the first window open :)

Link to comment
Share on other sites

Oh right I think I get what you want - you want an automatic timeout that makes the first window close and the next window open...

<script type="text/javascript">function verifyAnswer(){if(confirm("Are you sure?")){    return true;}else{    return false;}}function open_win(){    // only run the window.open code if the verifyAnswer    // function returns true.    if(verifyAnswer())    {viewTime = 5000; //Set the view time to 5000 msvar win = window.open("http://page1.html");setTimeout("win.close()", viewTime);win.onUnload = function(){  var win2 = window.open("http://page2.html");  setTimeout("win2.close()", viewTime);  win2.onUnload = function()  {    var win3 = window.open("http://page3.html");    setTimeout("win3.close()", viewTime);    win3.onUnload = function()    {      var win4 = window.open("http://page4.html");      setTimeout("win4.close()", viewTime);      win4.onUnload = function()      {        var win5 = window.open("http://page5.html");        setTimeout("win5.close()", viewTime);      }    }  }}    }}</script><input type="submit" value="Somevalue" name="gwar" onclick="open_win()" />

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...