...

View Full Version : Random Image with map



curvwind8
02-27-2007, 10:23 PM
Hello,

I used the thread at:
http://www.codingforums.com/showthread.php?t=88053&page=2

to do this and it works fine in safari, but in internet explorer or firefox the images do not show up. Could someone help?

The page is at flourisheveryday.com and here's my code:



<script language="JavaScript" type="text/javascript">
<!--

var myStrip = new Array()
myStrip[0]=['UserMods/template/home_large_09.png']
myStrip[1]=['UserMods/template/home_large_08.png']
myStrip[2]=['UserMods/template/home_large_07.png']
myStrip[3]=['UserMods/template/home_large_05.png']
myStrip[4]=['UserMods/template/home_large_10.png']
myStrip[5]=['UserMods/template/home_large_11.png']
myStrip[6]=['UserMods/template/home_large_12.png'];

var imgCt = myStrip.length;
var randomNum = Math.floor((Math.random() * 7));
var myMap = "#Map" + String(randomNum);

function chooseStrip() {
if (document.images) {
document.strip.src = myStrip[randomNum];
document.getElementById('strip').useMap = myMap;
}
}

//-->
</script>

<body onload="chooseStrip();">

<IMG SRC="UserMods/template/home_blank.png" NAME="strip" border="0" width=440 height=508 USEMAP="#Map0" ID="strip">

<MAP NAME="Map0" ID="Map0">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map1" ID="Map1">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map2" ID="Map2">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map3" ID="Map3">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map4" ID="Map4">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map5" ID="Map5">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map6" ID="Map6">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

vwphillips
02-27-2007, 10:46 PM
var myMap = "#Map" + randomNum;

curvwind8
02-27-2007, 10:56 PM
still no dice...

it doesn't seem to load the random images, only the "home_blank.png"

vwphillips
02-27-2007, 11:12 PM
<script language="JavaScript" type="text/javascript">
<!--
var path='http://www.vicsjavascripts.org.uk/StdImages/';

var myStrip = new Array()
myStrip[0]=[path+'One.gif']
myStrip[1]=[path+'Two.gif']
myStrip[2]=[path+'Three.gif']
myStrip[3]=[path+'Four.gif']
myStrip[4]=[path+'Five.gif']
myStrip[5]=[path+'Six.gif']
myStrip[6]=[path+'Seven.gif'];

var imgCt = myStrip.length;
var randomNum = Math.floor((Math.random() * 7));
var myMap = "#Map" + randomNum;

function chooseStrip() {
document.getElementById('strip').src = myStrip[randomNum];
document.getElementById('strip').useMap=myMap;
}

//-->
</script>

<body onload="chooseStrip();">

<IMG SRC="UserMods/template/home_blank.png" NAME="strip" border="0" width=440 height=508 USEMAP="#Map0" ID="strip">

<MAP NAME="Map0" ID="Map0">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map1" ID="Map1">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map2" ID="Map2">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map3" ID="Map3">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map4" ID="Map4">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map5" ID="Map5">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>

<MAP NAME="Map6" ID="Map6">
<AREA SHAPE="RECT" COORDS="131,473,352,493" HREF="scripts">
</MAP>
</body>
</html>

this works with IE and FF

maybe your images or image type.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum