Display image on refresh with link
-
I am trying to, on my homepage show just a sample of what is on my website using a certian number of images. The code I have already is (found code online): Code in header:
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com --><!-- Begin
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.theImages[0] = 'Images/Nepticulidae/Stigmella_Aurella/Stigmella_aurella_Adult1.jpg'
theImages[1] = 'Images/Lasiocampidae/Drinker/Drinker_Moth_Adult_Male1.jpg'
theImages[2] = 'Images/Geometridae/Pale%20Brindled%20Beauty/Pale_Brindled_Beauty_Tree.jpg'
theImages[3] = 'Images/Noctuidae/Cuculliinae/Early%20Grey/earlygrey_Rossa.jpg'
theImages[4] = 'Images/Noctuidae/The%20Satellite/Satellite_Yellow_Stigma1.jpg'
theImages[5] = 'Images/Nymphilidae/Painted_Lady/Painted_Lady_Road.jpg'
theImages[6] = 'Images/Nymphilidae/Small_Heath/Small_Heath_Resting1.jpg'
theImages[7] = 'Images/Nymphilidae/Meadow_Brown/Irish/Meadow_Brown_Flower.jpg'
theImages[8] = 'Images/Nymphilidae/Owl%20Butterflys/Caligo_Menom/Owl_Butterfly_Resting.jpg'
theImages[9] = 'Images/Pterophoridae/Stenoptilia_pterodactyla/Stenoptilia_pterodactyla_Adult1.jpg'
theImages[10] = 'Images/Pyralidae/Chrysoteuchia%20culmella/Chrysoteuchia_culmella_Adult2.jpg'
theImages[11] = 'Images/Sphinigidae/Eyed_Hawk_Moth/Eyed_Hawk_Moth_Resting1.jpg'
theImages[12] = 'Images/Tortricidae/Tortricinae/Syndemis%20musculana/Syndemis_musculana_Mating.JPG'
theImages[13] = 'Images/Unusual%20Moths/Tony%20Kingston/Popular%20Hawkmoth/Popular%20Hawkmoth%201.jpg'
theImages[14] = 'Images/Unusual%20Moths/Roger%20Skeen/Oleander_Hawk_Moth1.jpg'
theImages[15] = 'Images/Unusual%20Moths/Roger%20Skeen/Bastilla_crameri.jpg'// do not edit anything below this line
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}// End -->
</script>Code placed where I want the images displayed:
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -
I am trying to, on my homepage show just a sample of what is on my website using a certian number of images. The code I have already is (found code online): Code in header:
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com --><!-- Begin
// Set up the image files to be used.
var theImages = new Array() // do not change this
// To add more image files, continue with the
// pattern below, adding to the array.theImages[0] = 'Images/Nepticulidae/Stigmella_Aurella/Stigmella_aurella_Adult1.jpg'
theImages[1] = 'Images/Lasiocampidae/Drinker/Drinker_Moth_Adult_Male1.jpg'
theImages[2] = 'Images/Geometridae/Pale%20Brindled%20Beauty/Pale_Brindled_Beauty_Tree.jpg'
theImages[3] = 'Images/Noctuidae/Cuculliinae/Early%20Grey/earlygrey_Rossa.jpg'
theImages[4] = 'Images/Noctuidae/The%20Satellite/Satellite_Yellow_Stigma1.jpg'
theImages[5] = 'Images/Nymphilidae/Painted_Lady/Painted_Lady_Road.jpg'
theImages[6] = 'Images/Nymphilidae/Small_Heath/Small_Heath_Resting1.jpg'
theImages[7] = 'Images/Nymphilidae/Meadow_Brown/Irish/Meadow_Brown_Flower.jpg'
theImages[8] = 'Images/Nymphilidae/Owl%20Butterflys/Caligo_Menom/Owl_Butterfly_Resting.jpg'
theImages[9] = 'Images/Pterophoridae/Stenoptilia_pterodactyla/Stenoptilia_pterodactyla_Adult1.jpg'
theImages[10] = 'Images/Pyralidae/Chrysoteuchia%20culmella/Chrysoteuchia_culmella_Adult2.jpg'
theImages[11] = 'Images/Sphinigidae/Eyed_Hawk_Moth/Eyed_Hawk_Moth_Resting1.jpg'
theImages[12] = 'Images/Tortricidae/Tortricinae/Syndemis%20musculana/Syndemis_musculana_Mating.JPG'
theImages[13] = 'Images/Unusual%20Moths/Tony%20Kingston/Popular%20Hawkmoth/Popular%20Hawkmoth%201.jpg'
theImages[14] = 'Images/Unusual%20Moths/Roger%20Skeen/Oleander_Hawk_Moth1.jpg'
theImages[15] = 'Images/Unusual%20Moths/Roger%20Skeen/Bastilla_crameri.jpg'// do not edit anything below this line
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'">');
}// End -->
</script>Code placed where I want the images displayed:
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.comDave McCool wrote:
I would like below the image text saying what the species is and when you click the text (want text to be hyperlink)
it's like this ...
Dave McCool wrote:
var theImages = new Array()
Dave McCool wrote:
theImages[0] = 'Images/Nepticulidae/Stigmella_Aurella/Stigmella_aurella_Adult1.jpg' theImages[1] = 'Images/Lasiocampidae/Drinker/Drinker_Moth_Adult_Male1.jpg'
var theImages = new Array() ;
var theText = new Array() ;
var theLink = new Array();
theImages[0] = 'Images/Nepticulidae/Stigmella_Aurella/Stigmella_aurella_Adult1.jpg';
theText[0] = "This is a butterfly?";
theLink [0]= 'HTMLfiles/Nepticulidae/Stigmella_Aurella.html';
theImages[1] = 'Images/Lasiocampidae/Drinker/Drinker_Moth_Adult_Male1.jpg';
theLink[1] = 'HTMLfiles/Lasiocampidae/Drinker.html';
theText[1] = "This butter is fly?"Dave McCool wrote:
function showImage(){document.write('<img src="'+theImages[whichImage]+'">');}
function showImage(){
document.write('<table><tr><td>');
document.write('<img src="'+theImages[whichImage]+'">');
document.write('</td></tr><tr><td>');
document.write('<a href =' + theLink[whichImage] + '>');
document.write(theText[whichImage]);
document.write('</a>');
document.write('</td></tr></table>');
}this is very close to what you are asking