Results 1 to 5 of 5

Thread: How to change this... [resolved]

  1. #1

    Thread Starter
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Arrow 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?

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    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

  3. #3
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    RealisticGraphics, shouldn't the setinterval() be placed within the function? Maybe I'm missing something, but wouldn't that just have picksite() once?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    ah ha. I see now.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width