Reply
Random page generator
Old 06-22-2005, 05:19 AM Random page generator
Experienced Talker

Posts: 35
Hi Guys,

On my site I want to have a script so that when you go to www.nameofmysite.com the script in that< head> loads in a random page.

ie, when I go to www.nameofmysite.com it could load:

either
www.nameofmysite.com/page1.html
or
www.nameofmysite.com/page2.html
or
www.nameofmysite.com/page3.html

Is there a script that does this. I know it can be done with one image using javascript, but I want it to call a random page, not just images?

Can anyone point me in the right direction or post a url to a script?

Thanks

Chris
chrisb is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 06-28-2005, 07:30 PM
Skorch's Avatar
Super Talker

Posts: 115
Location: California
Could you just find a random image script and replace the filename.jpg with pagename.html? It should work!
__________________
Check out my Cliff Diving website!
Skorch is offline
Reply With Quote
View Public Profile Visit Skorch's homepage!
 
Old 06-28-2005, 07:38 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
PHP and Unicode with UTF-8
Posts: 3,111
Location: Toronto, Ontario
You can't really do it with Javascript, but you can emulate it by randomly selecting a URL and then redirecting the user to that page.
Christopher is offline
Reply With Quote
View Public Profile Visit Christopher's homepage!
 
Old 06-28-2005, 11:23 PM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Here's an example, modifying some of Chroder's code from another post:
Code:
<html> 
  <head>
    <script> 
      var url1 = "http://www.google.com";
      var url2 = "http://www.microsoft.com";
      var url3 = "http://www.webmaster-talk.com";
		 
      var urlArray = [url1, url2, url3]; 
      var rand = Math.round(Math.random() * (urlArray.length - 1) ); 
      var redirectURL = urlArray[rand];
		
      window.location = redirectURL;
    </script> 
  </head> 
  <body>

    <p>
      Here's some text that shouldn't ever be seen, except of course by people who don't have JavaScript-enabled browsers.
    </p>

  </body> 
</html>
__________________
Free Teacher Websites
Phaedrus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Random page generator
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12154 seconds with 12 queries