Forum Moderators: phranque

Message Too Old, No Replies

Single Link to Various URLs

         

gitCHuONe

7:02 pm on Jun 25, 2009 (gmt 0)

10+ Year Member



I'm not entirely sure where this question would go, or what it's specifically called, so I am posting it here.

What I am trying to accomplish is to have a single text link on a page that will direct to a random list of URLs when clicked. I'm not even sure if that makes sense. I want to build a list of URLs, and through a single link on my page, the direction will go to any of the links in the list randomly.

Is this possible, and does anyone have any information on how I can accomplish this?

Thanks!

rocknbil

11:56 pm on Jun 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard gitCHuONe, I can think of two ways right off.

The one that will always work is a server-side method;

href="random-url-script.php"

I used PHP because that's what everyone seems to like these days, it can be PHP, ASP, Perl, Cold Fusion . . . whatever.

The second is the same thing with Javascript. The down side of this is it won't work for Javascript-disabled browsers and the URL's are likely not to index in SERPS.

In both cases, you'd have a list of URL's (array) and use random generation methods to get the random url. That is, if you have 20 URL's, you'd pick a random number between 0 and 19 (arrays are zero-based, the first index is 0.)

It gets a little more complex for redundant calls; to avoid picking the same number twice you need to create a second array of "visited" URL's. If the pick is in the "remembered" array, keep picking until you get one. If the remembered array has all the elements of the original, reset it.

gitCHuONe

5:40 am on Jun 26, 2009 (gmt 0)

10+ Year Member



Excellent. Yeah so at least I know it IS possible. The rest is probably over my head though.

Thanks.

piatkow

8:21 am on Jun 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can find lots of free script libraries on the web. You may need to hack a couple and combine them to get the result but still easier than starting from scratch.