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 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Redirecting randomly from index file to other html file

    Hi,

    Every time a user comes to my home page i.e. the main index file I would like a script to run so a different and random page of my website is viewed each time. I want to make vijf different index files like index_1.htm up to index_5.htm.

    I doe not have php, so that why I'm asking you javascript guys
    I have no experience with script writing.

    Is this randomly redirecting possible in all, ie, firefox and Google, and is there someone willing to help me with this?

    Thanks
    Hagar

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Put this in the head.
    Code:
    <script type="text/javascript">
    (function() {
        var rand = Math.ceil(Math.random()*5);
        location.replace('index_' + rand + '.htm');
    })();
    </script>


  •  

    Posting Permissions

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