Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascripting question for java experts :-)

Status
Not open for further replies.

RedWulf

MIS
Aug 30, 2001
2
US
I have a random image script that i want to run. However, im also looking to have it set so that when a random image comes up each image will link to a differnt page. I only have four images that i want to cycle....

Does anyone know where i can find an example, coding explaining this...or has any idea as to how to make this work? (if possible)

thank you
 
RedWulf,

here's what i have used in the past:

<SCRIPT LANGUAGE=JavaScript>
<!--
// place this in your document body where you want the image to appear:

Code:
gfx0=&quot;pic01.gif&quot;;
// your first img
Code:
lnk0=&quot;[URL unfurl="true"]http://www.pic01url.com&quot;;[/URL]
// img 1's url
Code:
gfx1=&quot;pic02.jpg&quot;;
// your second img
Code:
lnk1=&quot;[URL unfurl="true"]http://www.pic02url.com&quot;;[/URL]
// img 2's url
Code:
gfx2=&quot;pic03.gif&quot;;
// your 3rd img
Code:
lnk2=&quot;#&quot;;
// just in case ya dont want it to go anywhere

Code:
len=3;
// important: len (for length) must be equal to the number of img/url's you have above ...including the 0,1,2
Code:
today=new Date();
// dont change
Code:
today=today.getTime()/10;
// dont change
Code:
rnd=today%len;
// dont change

// this writes it:
Code:
document.writeln('<A HREF=&quot;'+eval(&quot;lnk&quot;+rnd)+'&quot;><IMG SRC=&quot;'+eval(&quot;gfx&quot;+rnd)+'&quot; BORDER=&quot;0&quot;></A>');
//-->
</SCRIPT> Hope it helps ;)

~ jsLove
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top