|
Web design and Programming Discuss website creation and other programming topics. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
Random Image Generator + Address?
So, i want to know if anyone can modify this javascript for me to make the random images appear as clickable links.
Any help is appreciated. Code:
<script language="JavaScript"> <!-- function random_imglink(){ var myimages=new Array() //specify random images below. You can have as many as you wish myimages[1]="image1.gif" myimages[2]="image2.gif" myimages[3]="image3.gif" myimages[4]="image4.gif" myimages[5]="image5.gif" myimages[6]="image6.gif" var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<img src="'+myimages[ry]+'" border=0>') } random_imglink() //--> </script>
__________________
Quote:
|
#2
|
||
|
Code:
<script language="JavaScript"> <!-- function random_imglink(){ var myimages=new Array() //specify random images below. You can have as many as you wish myimages[1]="image1.gif" myimages[2]="image2.gif" myimages[3]="image3.gif" myimages[4]="image4.gif" myimages[5]="image5.gif" myimages[6]="image6.gif" var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<a href="'+myimages[ry]+'"><img src="'+myimages[ry]+'" border=0></a>') } //--> </script>
__________________
|
#3
|
||
|
Assuming you want them to link to the images?
|
#4
|
||
|
Yeah, what I posted assumes that. You'd need to link an array of addresses otherwise.
__________________
|
#5
|
||||
|
Quote:
I want the images to link to an outside like, like a forum post or something. So say I want the image to link to www.xoxide.com.
__________________
Quote:
|
#6
|
||
|
Yeah you'd just create another array and match the indexes;
Code:
<script language="JavaScript"> <!-- function random_imglink(){ var myimages=new Array() //specify random images below. You can have as many as you wish myimages[1]="image1.gif" myimages[2]="image2.gif" myimages[3]="image3.gif" myimages[4]="image4.gif" myimages[5]="image5.gif" myimages[6]="image6.gif" var imageLinks = new Array(); imageLinks[1]="www.google.com"; imageLinks[2]="www.blackzone.com"; imageLinks[3]="www.somethingstupid.com"; imageLinks[4]="www.ifailedsquared.com"; imageLinks[5]="www.blah.com"; imageLinks[6]="www.shiz.com"; var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<a href="'+imageLinks[ry]+'"><img src="'+myimages[ry]+'" border=0></a>') } //--> </script>
__________________
|
#7
|
|||
|
Sweet! Thank you, kind sir!
__________________
Quote:
Last edited by EDGE; 12-09-2010 at 04:17 PM. |
#8
|
||
|
Np
__________________
|
#9
|
|||
|
I have another question ath. Do you know of any scripts that show scrolling images, like the news image on this site - www.worldofwarcraft.com ? I'm not too sure what the script it called nor where to find one.
__________________
Quote:
|
#10
|
||
|
Ah, like a slideshow?
If that's what you're talking about then yeah, there's one called jcycle. It is way easy to use and it uses the jquery library. This is their site: http://jquery.malsup.com/cycle/ There might be a better one but that's the one I am using right now.
__________________
|
#11
|
||
|
BTW, if you want to use jCycle I'd look at the pager functionality and the other advanced options.
__________________
|
#12
|
|||
|
Thanks, bro. It works perfectly!
__________________
Quote:
|
#13
|
||
|
glad it works for yah.
__________________
|
#14
|
||
|
Why do your arrays not start at zero? This makes me sad.
__________________
04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq |
#15
|
||
|
Hehe, I was going to mention that but figured I wouldn't to avoid confusing people.
__________________
|
#16
|
||
|
Hah, you can have a big Like.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
MS Points Generator...Does this really work? | Bustin | Gaming Talk | 5 | 04-12-2010 10:39 PM |
Advertisement slogan generator! | Steve | General Chat | 30 | 06-02-2005 02:29 PM |
Squad Tag Generator | Surge | Web design and Programming | 2 | 01-21-2004 05:52 AM |
Random Tree/object Generator for TFD? | RoDent | Delta Force | 2 | 05-13-2003 12:19 AM |
Random Image | Matt | Web design and Programming | 4 | 04-16-2003 04:14 PM |