Forum Moderators: open
content[0] = "http://www.website.com/something.txt";
content[1] = "http://www.website.com/something.txt";
content[2] = "http://www.website.com/something.txt";
var counter = 0;
function secondsplus_iframe()
{ document.getElementById("dynstuff").src = content[counter];
counter++; if (counter == content.length)
counter = 0; } setInterval("secondsplus_iframe()", 3600000);
I see from your code that it is obvious that the counter starts from zero since your first line is var counter = 0;
You could use a cookie like the others above said, but I try not to use cookies anymore because people disable them in their web browsers. Using cookies will run you this risk and then what will you do?
Like I said, Ajax is probably the better way to go since it will work without worrying if someone turned off their cookies.
With Ajax, you can use a simple PHP or ASP script and have the script keep track of your variable. The good thing about using Ajax is that the web browser will never leave your web page.
Your first lines of Javascript should be:
var counter = AjaxCounter; NOT var counter = 0
The Ajax will keep track of your item number. It will then send that number to your PHP script to increment it by one and return it as an Ajax responseText property. From that point, your line of javascript will be document.getElementById("dynstuff").src = AjaxCounter instead of content[AjaxCounter]
From there, when your setInterval("secondsplus_iframe()", 3600000) activates, your src property will just change via the Http request created by the Ajax.
I hope this helps. Read up on Ajax at W3Schools. W3schools nails the basics of Ajax for you pretty quickly.
Bruce