1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

random index page

Discussion in 'Software Development' started by ckaas, Feb 4, 2003.

Thread Status:
Not open for further replies.
Advertisement
  1. ckaas

    ckaas Thread Starter

    Joined:
    Feb 3, 2003
    Messages:
    133
    hello all, i was wondering how one sets up a website so that the index page is different everytime it loads? some sites like starwars.com use this, the index page is different everytime one reloads the page. how do one do this? :) thanks
     
  2. ckaas

    ckaas Thread Starter

    Joined:
    Feb 3, 2003
    Messages:
    133
    the server is NT 4.0, if that helps...
     
  3. Memnoch1207

    Memnoch1207

    Joined:
    Dec 27, 2002
    Messages:
    10
    view the source code for the page...it's javascript.
     
  4. ckaas

    ckaas Thread Starter

    Joined:
    Feb 3, 2003
    Messages:
    133
    yeah i notice the javascript, but could you point out at what point it determines what set of images are to be loaded, i'm a bit slow you see, for these things... thanks.
     
  5. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Its not a different page, just a random image Javascript.
    Search at Javascriptsource.com theres like 2 dozen scripts for this.
     
  6. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Here's a quicky you can modify to suit your needs:

    PHP:
        <SCRIPT LANGUAGE="Javascript">
                <!--
                    var 
    randNumber Math.round(Math.random() * 4)
                    if (
    randNumber == 0)
                    {
                    
    document.write('<A href="http://www.intel.com">Intel</A><br><A href="http://www.cisco.com">Cisco</A>');
                    }
                    if (
    randNumber == 1)
                    {
                    
    document.write('<A href="http://forums.techguy.org/">Tech Guy</A><br><a href="http://www.4guysfromrolla.com/">4 Guys from Rolla</a>');
                    }
                    if (
    randNumber == 2)
                    {
                    
    document.write('So What!');
                    }
                    if (
    randNumber == 3)
                    {
                    
    document.write('Sumthin...Sumthin');
                    }
                    if (
    randNumber == 4)
                    {
                    
    document.write('You first');
                    }
                
    // -->
                
    </SCRIPT>

    Copy and paste it into the body of any web page. If you want more random indexes just change the variable *4 so the script can tell what number of random numbers to select from.
     
  7. ckaas

    ckaas Thread Starter

    Joined:
    Feb 3, 2003
    Messages:
    133
    thanks rockn, if i were to replace document.write by document.replace and specified another page, would that work also? :)
     
  8. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    The replace function is meant to replace something in a string. Say there were commas in a text string that you wanted to replace with semi-colons document.replace('textstring, ",", ";")

    Something like that.
     
  9. ckaas

    ckaas Thread Starter

    Joined:
    Feb 3, 2003
    Messages:
    133
    okay, thanks for all the help! :)
     
  10. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/117025

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice