random image and its url
Posted
by
venom
on Stack Overflow
See other posts from Stack Overflow
or by venom
Published on 2010-12-21T11:43:51Z
Indexed on
2010/12/21
11:54 UTC
Read the original article
Hit count: 199
i want to create a random image and its url, i mean not the link of the image, but in addition to image's link, i want the specified URL, so that random image was displayed and when u click on it, u go to the specified URL
here is my javascript:
function random_imglink(){
var myimages=new Array()
//specify random images below. You can have as many as you wish
myimages[1]="/documents/templates/projedepo/banner/canon.jpg"
myimages[2]="/documents/templates/projedepo/banner/indigovision.jpg"
var ry=Math.floor(Math.random()*myimages.length)
if (ry==0)
ry=1
var randomImage = '<img src="'+myimages[ry]+'" height="420" width="964" />';
document.getElementById("image2").innerHTML = randomImage;
}
random_imglink()
Here is my HTML:
<div id="slider_container">
<div id="image2">
</div>
<div id="thumb2">
<a href="#" rel="/documents/templates/projedepo/banner/canon.jpg" class="image2" ><img title="Canon" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t1.png" border="0"/></a>
<a href="#" rel="/documents/templates/projedepo/banner/indigovision.jpg" class="image2"><img title="IndogoVision" class="slider_thumb" src="/documents/templates/bilgiteknolojileri/images/t_flash/t2.png" border="0"/></a>
</div></div>
© Stack Overflow or respective owner