# Random URL

**URL:** <https://forum.kirupa.com/t/random-url/15818>\
**Category:** Uncategorized\
**Created:** [March 18, 2003, 10:44am UTC](https://forum.kirupa.com/t/random-url/15818 "2003-03-18T10:44:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)\
**Post date:** [March 18, 2003, 10:44am UTC](https://forum.kirupa.com/t/random-url/15818/1 "2003-03-18T10:44:22Z")

</div>

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! =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 18, 2003, 6:05pm UTC](https://forum.kirupa.com/t/random-url/15818/2 "2003-03-18T18:05:26Z")

</div>

you could do something like the following:

place this in the head section of your page:

```php
<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:

```php
<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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 18, 2003, 6:08pm UTC](https://forum.kirupa.com/t/random-url/15818/3 "2003-03-18T18:08:07Z")

</div>

> \*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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 18, 2003, 6:12pm UTC](https://forum.kirupa.com/t/random-url/15818/4 "2003-03-18T18:12:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 18, 2003, 6:17pm UTC](https://forum.kirupa.com/t/random-url/15818/5 "2003-03-18T18:17:10Z")

</div>

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 :-\

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 19, 2003, 10:22am UTC](https://forum.kirupa.com/t/random-url/15818/6 "2003-03-19T10:22:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 19, 2003, 5:44pm UTC](https://forum.kirupa.com/t/random-url/15818/7 "2003-03-19T17:44:12Z")

</div>

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