JavaScript: 2 window.opener.location.href statements with alert() in between not functioning

Posted by vastbeyond on Stack Overflow See other posts from Stack Overflow or by vastbeyond
Published on 2010-06-08T00:35:03Z Indexed on 2010/06/08 0:52 UTC
Read the original article Hit count: 296

Filed under:
|
|

I need to make a little JS app to scroll automatically through a list of URLs. I've chosen to have the functionality in a pop-up, for various reasons.

The syntax to change the opening window's URL is:

window.opener.location.href = "http://www.example.com";

This works fine with one URL, but if two statements are called, only one is executed. I experimented with an alert statement between two of the above statements, and the alert event made the second statement function properly:

window.opener.location.href = "http://www.example1.com";
alert("hello world");
window.opener.location.href = "http://www.example2.com";

Question is: does anyone know how to get the first and second window.opener statements to work, without the intervening alert();? Also, how can I add a pause between the two statements, so that the second executes a couple of seconds after the first?

Thanks so much!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about window