Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need a script for a random page after a random time

    Can anyone help ? - Anyone used one / seen one ?

    I need a page to load and then, after a random period of time between two variables, it loads a page, and I want that page to be random.

    I have found two script that do each of the above but I do not have the skill required to combine them to do what I need ?

    Can you help....

    Thanks,

    Justin Smith

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    you could do something like this


    var urls = new Array()
    urls[0] = "http://google.com"
    urls[1] = "http://yahoo.com"
    urls[2] = "http://amazon.com"
    urls[3] = "http://codingforums.com"

    function startr() {
    var mintime = 1000
    var maxtime = 5000
    setTimeout("randomloc()" ((Math.random()*(maxtime-mintime))+mintime))
    }
    function randomloc() {
    location.href = urls[Math.random()*urls.length]
    }

    and then have in the body tag a onload="startr()"
    Kris Hubby
    kwhubby site


  •  

    Posting Permissions

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