Click to See Complete Forum and Search --> : Code to cycle between pages
Hi,
I need some Jscript (or ideas on which function to look at) which will cycle between 3 /4 different web pages. These are on the same webserver but in different virtual folders.
The code should display 1 page for x seconds , refresh to the 2nd page, etc etc and then start the cycle again.
Any ideas?
Dean
AdamGundry
04-17-2003, 03:34 AM
You don't need Javascript, you can do this with a HTML <meta> tag. Put something like this in the <head> section of each page:
<meta http-equiv="refresh" content="5; URL=http://www.example.com/">
The number 5 is the time from loading to refresh (in seconds), and the URL is the page to refresh to. You can omit this to simply refresh the same page.
Adam
P.S. Be aware this can be disabled/not work in some browsers, so make sure there is some other way of accessing the content.
The pages that I want to view are dynamic and generated from code that I can't access - They come from a 3rd party product. Hence I need code that will run and call these pages by URL independantly of the actual pages.
Thanks
Dean
AdamGundry
04-17-2003, 04:24 AM
I presume you are loading them in an iframe or frame, if so then try something like this (untested):
<script type="text/javascript">
function Cycle(step){
if (step == 0){
top.framename.location.href = 'page1.html';
setTimeout("Cycle(1)", 1000);
}
if (step == 1){
top.framename.location.href = 'page2.html';
setTimeout("Cycle(2)", 1000);
}
if (step == 2){
top.framename.location.href = 'page3.html';
setTimeout("Cycle(0)", 1000);
}
}
</script>
Call Cycle(0) to start the script, for example when the page loads: <body onload="Cycle(0)">
Adam