Author Topic: Random Link  (Read 1810 times)

Offline SurfSmarter

  • Sr Member
  • Posts: 518
    • View Profile
Random Link
« on: March 30, 2011, 02:44:39 PM »
Mark et al,

I appear to be getting thick in my old age, and i'm not referring just to the waistline, lol. So I must defer to anyone whose age isn't affecting them to the same degree...

How can I set random/rotated link(s) to appear in the footer of a site?

The link(s) would be called from a single simple source file (maybe .txt or html) hosted on a separate server.

Basically use would be as a "sponsored by theme" but each 'fresh' load would pull a different click-able text link from the master list.

Any insight is alway appreciated


Offline Mark Austin

  • Admin
  • Posts: 7,961
  • Life is like photography. Use negatives to develop
    • View Profile
    • Resell Rights Weekly
Re: Random Link
« Reply #1 on: March 30, 2011, 03:58:09 PM »
Hi John,

Here's what I use on WP:

Code: [Select]
<a href="[php]echo rand(1, 10);[/php].php">Click here</a>

Which results in "" through ""

For "regular" site:

Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<script type="text/javascript"><!--
var links = new Array();

function getRandomLink() {
var randomNum = Math.floor(Math.random()*links.length);
window.location = links[randomNum];

<form name="" action="">
<input type="button" value="Click Here!" onclick="getRandomLink()" />

Hope that helps,
“Keep away from people who try to belittle your ambitions. Small people always do that,
but the really great makes you feel that you, too, can become great.”
~ Mark Twain

Offline SurfSmarter

  • Sr Member
  • Posts: 518
    • View Profile
Re: Random Link
« Reply #2 on: March 31, 2011, 12:38:13 PM »
Thanks Mark

Will try this on the weekend.