User Name
Password
AppleNova Forums » Programmer's Nook »

Random homepage


Register Members List Calendar Search FAQ Posting Guidelines
Random homepage
Thread Tools
rasmits
rams it
 
Join Date: Oct 2004
Location: Seattle
 
2005-12-18, 20:46

Let's say I have 4 or 5 versions of the same homepage, how can I randomize it so when a user enters the address, there are a couple options as to what they'll see?
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2005-12-18, 20:48

You'll need server-side scripting, such as PHP, to do that.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-12-18, 20:49

Or JavaScript if you don't mind forwarding the person to another page.
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2005-12-18, 20:50

True. Either way, it's rather simple to pull off. Of course, I'm a lazy bum and won't say how.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-12-18, 20:54

Yeah, ditto. That's what Google's for.
  quote
rasmits
rams it
 
Join Date: Oct 2004
Location: Seattle
 
2005-12-18, 21:10

Well, I guess it's not that important, I was just wondering. Thanks anyway.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-12-18, 21:11

Well, here... I'll move this thread over to the Programmer's Nook where you may get a better response.
  quote
Chinney
Veteran Member
 
Join Date: May 2004
Location: Ottawa, ON
 
2005-12-18, 21:20

Interesting idea Rasmits. But when I saw the title of this thread - and before I saw what you actually meant by the title - my mind immediately jumped to another interesting idea: being able to program your browser so that every time you opened it, it took you to a random place on the internet. I like that idea. You might want to set a few parameters in advance with respect to content (or not!). Broaden your horizons.

When there's an eel in the lake that's as long as a snake that's a moray.
  quote
rasmits
rams it
 
Join Date: Oct 2004
Location: Seattle
 
2005-12-18, 21:38

Thats a cool idea too, though, 90% of the results wouldn't be very flattering.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-12-18, 21:53

Well, here's a quick and dirty way of doing what I think you want, rasmits.

[php]<?php
$pages = array("index1.html","index2.html","index3.html","i ndex4.html");
$destination = rand(0,sizeof($pages)-1);
header("Location:".$pages[$destination]);
?>[/php]

Save that as index.php and it'll redirect the visitor to one of the links in the $pages array. Be sure you don't have anything before the opening "<?php" otherwise the redirect will fail.

If you want the random page to appear to be at this location (ie. the user won't see a redirect and won't see the URL of the random pages), change it to work like this:

[php]<?php
$pages = array("index1.html","index2.html","index3.html","i ndex4.html");
$destination = rand(0,sizeof($pages)-1);
include $pages[$destination];
?>[/php]

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
rasmits
rams it
 
Join Date: Oct 2004
Location: Seattle
 
2005-12-18, 23:02

Awesome, thank you very much.
  quote
Posting Rules Navigation
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

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving Frontpage website to .Mac Homepage? bosox Genius Bar 0 2005-04-27 11:48
.Mac Homepage not responsive Benners72 Genius Bar 5 2005-02-12 09:06
some random questions.. ironlung Third-Party Products 9 2005-02-10 01:20
Random mac questions porter Genius Bar 3 2005-01-23 14:37
random drug testing Mac+ AppleOutsider 18 2004-12-14 08:28


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 11:23.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova