1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do i redirect users to sites at random

Discussion in 'General Scripting Chat' started by Inception_AC, Jul 18, 2011.

  1. Inception_AC

    Inception_AC Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Feb 16, 2011
    Messages:
    1,620
    Likes Received:
    1,131
  2. wowhaxor

    wowhaxor Executive VIP Premium Member

    Joined:
    Apr 28, 2007
    Messages:
    2,021
    Likes Received:
    3,353
    Location:
    ?¿?
    Home Page:
    If they have JS enabled then:
    Code:
    <script type="text/javascript">
    
    var urls = new Array("http://www.url1.com/", "http://www.url2.com/");
    
    function redirect()
    {
    window.location = urls[Math.floor(urls.length*Math.random())];
    }
    
    var temp = setInterval("redirect()", 3000);
    
    </script> 
    Its probably best to do it in PHP though but I dunno exactly how to do variables in PHP, Google it yo!
     
    • Thanks Thanks x 1
  3. Inception_AC

    Inception_AC Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Feb 16, 2011
    Messages:
    1,620
    Likes Received:
    1,131
    Thanks it works :)
     
  4. KraftyKyle

    KraftyKyle Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Aug 13, 2008
    Messages:
    1,941
    Likes Received:
    4,609
    Gender:
    Male
    Location:
    Unknown
    I have a randout.php file that picks from the links in randout.txt file at random. PM me and I'll send you the code.
     
  5. Hebimage

    Hebimage Newbie

    Joined:
    Jul 17, 2011
    Messages:
    19
    Likes Received:
    0
    Home Page:
    But do a
    Code:
    <noscript>Please click here to get redirected</noscript>
    for people who don't have JS activated.