Random URL

ok workin’ on a footer! I think I’m gonna just put pics! No flash!
But I want it to load a random URL! Like a random pic chosen from various pics! how? please~pretty please! =)

you could do something like the following:

place this in the head section of your page:

<SCRIPT language="javascript">
function RandomURL(text,urls)
{
RandomURLLong(text,urls,"");
}

function RandomURLLong(text,urls,hparams)
{
/* si: start index 
** i: current index
** ei: end index
** cc: current count
*/
 si = 0; 
 ci=0;
 cc=0;
 urlSet = new Array();
 ei = urls.length;
  for (i=1;i<ei;i++) {
    if (urls.charAt(i) == ' ' || urls.charAt(i) == ',') {
      urlSet[cc] = urls.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  ind = Math.floor(Math.random() *cc);
  document.writeln("<a "+hparams +" href=\""+urlSet[ind]+"\">"+text+"</a>");
}
</SCRIPT>

then, place the following where you’d like to add the random link:

<SCRIPT>
RandomURL("<h3>Click here for a random URL</h3>","http://www.vmkdsn.com/","http://www.imark-media.com","http://www.kirupaforum.com","http://www.thefirmdesign.com/",");
</SCRIPT>

Simply change the URL’s i’ve used to ones that you want and voila, it should work. On each page refresh, the link will take you to a different site.

*Originally posted by Syko *
**ok workin’ on a footer! I think I’m gonna just put pics! No flash!
But I want it to load a random URL! Like a random pic chosen from various pics! how? please~pretty please! =) **

You can’t use Javascript in your footer. It doesn’t work.

You can however dynamically load .jpgs into Flash (as long as they are a good file size).

To do that would be easy, just store the image names in an array, then pic from that array randomly and load it in.

oh yeah… forgot… well anyways that code should still work if you wanna do it on a webpage…

Actually for random image displaying, you could do the same. Just choose an image file name randomly from an array. The code would be much shorter and easier :-\

oh yeah! Why didn’t I think of flash?=)

:slight_smile: Its pretty much your only choice for randomness in your footer. Jubbas footer uses the same method, he randomly loads in 3 different images.