user3102390
user3102390

Reputation: 1

How can I add a click button cycle URL function (that flips between urls in given order) to this script or is it possible?

How can I add a click button cycle URL function (that cycles between urls in given order) to this script or is it possible?

<script type="text/javascript">
var urls = new Array();
urls[0] = "facebook.com";
urls[1] = "yahoo.com";
var random = Math.floor(Math.random()*urls.length);
window.location = urls[random];

</script>

Upvotes: 0

Views: 86

Answers (1)

AbsoluteƵER&#216;
AbsoluteƵER&#216;

Reputation: 7880

You can't make it "rotate" or "cycle" in this fashion because once you set the window.location to a new location, the page with this script on it is no longer running in the browser.

You would need to setup a frame that controls another frame in order to accomplish this. Then you could update the contents of the target frame. Also note that using random() is not making the urls show in sequence either.

Upvotes: 1

Related Questions