Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 35
Trades: 0
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
 
 
Register now for full access!
Old 06-28-2005, 08:30 PM
Skorch1's Avatar
Super Talker

Posts: 115
Location: California
Trades: 0
Could you just find a random image script and replace the filename.jpg with pagename.html? It should work!
__________________
Check out my
Please login or register to view this content. Registration is FREE
website!
Skorch1 is offline
Reply With Quote
View Public Profile Visit Skorch1's homepage!
 
Old 06-28-2005, 08:38 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 06-29-2005, 12:23 AM
Phaedrus's Avatar
Ultra Talker

Posts: 271
Location: CA
Trades: 0
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>
__________________

Please login or register to view this content. Registration is FREE
Phaedrus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Random page generator
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.14193 seconds with 12 queries