problem with random images+link+caption - Java, random images+link+caption won't display |
problem with random images+link+caption - Java, random images+link+caption won't display |
Jamesge |
Mar 2 2010, 01:08 PM
Post
#1
|
Group: Members Posts: 2 Joined: 2-March 10 Member No.: 11,262 |
Hi, I want to have a random image (one of several possilbe images) displayed on my page which will also link to another page and also has a text caption below it specific to each individual image. I have found several javascripts on the net which have worked for the people who requested them, but I can't get any of them to work. I have used a few javascripts already that work, so I know my computer will run them, but as I said the random image generators never work. Unfortunately I have a very limited understanding of Javascript. Here is one of my attempts to incorporate the javascript into a web page, the script comes from:
http://www.bluehostforum.com/showthread.php?t=9716 I am using it here: www.toy-pod.com/javatest.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Title here</title> </head> <body bgcolor="#000000" text="#d3d3d3" link="#ffc700" alink="#FFFF00" vlink="#ffc700"> <script type="text/javascript"> var imagenumber = 3 ; var randomnumber = Math.random() ; var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ; var image = images[rand1] var Quotation=new Array() images = new Array images[1] = "images/abouttoypod/hansolobike2.jpg" images[2] = "images/ads/adspacehoriz.jpg" images[3] = "images/ads/adspacevert2.jpg" links = new Array links[1] = "http://www.bluehostforums.com" links[2] = "http://www.withfriendship.com" links[3] = "http://www.funmin.com" Quotation[1] = "nice"; Quotation[2] = "befriendly"; Quotation[3] = "funny"; var Q = Quotation.length; var whichQuotation=Math.round(Math.random()*(Q-1)); function showQuotation(){document.write(Quotation[whichQuotation]);} showQuotation(); document.write('<a href="' + link + '"><img src="' + image + '" border="0"></a>') </script> </body> </html> This post has been edited by Jamesge: Mar 2 2010, 01:10 PM |
Lo-Fi Version | Time is now: 26th April 2024 - 06:10 PM |