|
-
Sep 7th, 2003, 08:42 AM
#1
Thread Starter
Frenzied Member
How to change this... [resolved]
I want to change this code into a code that instead of clicking a button does the feature evry 310 seconds all on its own..
How would i do it?
Heres the code...
Code:
<html>
<head>
<SCRIPT type="text/javascript">
newurls=new Array()
newurls[0]="http://www.outwar.com/page.php?x=530740"
newurls[1]="http://www.outwar.com/page.php?x=530740"
newurls[2]="http://www.outwar.com/page.php?x=799044"
newurls[3]="http://www.outwar.com/page.php?x=560612"
function picksite()
{
now=new Date()
num=(now.getSeconds())%4
top.location.href = newurls[num]
}
</script>
</head>
<body>
<center>
<h2>!Click after 5 mins!</h2>
<form>
<input type="button"
value="Click Here"
onClick="picksite()">
</form>
</center>
</body>
</html>
(this is actually my favourite script that i've made this year)
Well ant ideas like say a countdown timer with VAR seconds or something?
I will need th entire script back because last time i messed up
Thanks in advance
Last edited by thegreatone; May 20th, 2005 at 01:24 PM.
Zeegnahtuer?
-
Sep 7th, 2003, 08:52 AM
#2
Fanatic Member
Just us the setInterval function. Add it right after the pick site function.
Code:
<html>
<head>
<SCRIPT type="text/javascript">
newurls=new Array()
newurls[0]="http://www.outwar.com/page.php?x=530740"
newurls[1]="http://www.outwar.com/page.php?x=530740"
newurls[2]="http://www.outwar.com/page.php?x=799044"
newurls[3]="http://www.outwar.com/page.php?x=560612"
function picksite()
{
now=new Date()
num=(now.getSeconds())%4
top.location.href = newurls[num]
}
setInterval(picksite, 310000); //310,000 milliseconds in 310 seconds.
</script>
</head>
<body>
<center>
PickSite will be called every 310 seconds.
</center>
</body>
</html>
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Sep 7th, 2003, 01:41 PM
#3
Stuck in the 80s
RealisticGraphics, shouldn't the setinterval() be placed within the function? Maybe I'm missing something, but wouldn't that just have picksite() once?
-
Sep 7th, 2003, 03:18 PM
#4
No, setInterval fires continously until cleared with clearInterval (or something like that). The function you refer to is setTimeout, which fires only once.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 7th, 2003, 03:35 PM
#5
Stuck in the 80s
ah ha. I see now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|