Click to See Complete Forum and Search --> : Question for refresh page with random images


jjj-ccc
10-20-2003, 04:19 PM
Hi,
I saw the source code on this page
http://javascript.internet.com/miscellaneous/random-image.html
and wondering if I can add link on each image. So once user click on the image will go to a new page.

Please help!

Thanks

fredmv
10-20-2003, 04:30 PM
Welcome to the forums.

Here's a simple script I just put together:<script type="text/javascript">
var urls = ["http://www.google.com/", "http://www.yahoo.com/", "http://www.hotbot.com/"];
var imgs = ["http://forums.webdeveloper.com/images/top_profile.gif", "http://forums.webdeveloper.com/images/top_register.gif", "http://forums.webdeveloper.com/images/top_calendar.gif"];
var n = Math.floor( Math.random() * urls.length );
document.writeln( '<a href="' + urls[n] + '"><img src="' + imgs[n] + '" alt="" style="border: 0px;" /></a>' );
</script>I hope that helps you out.