Displaying a random image

R

robbiehenry

There is this javascript reference site that I often use and I was
looking for some script that would randomly show one of three images on
page refresh.

Here is the reference site that I use:
http://www.chalcedony.com/javascript/scripts/index.html

Here is their example:
http://www.chalcedony.com/javascript/scripts/index.html

Here is the page that I built for my company's site:
http://www.otpp.com/web/website.nsf/web/newgraduates&students

This works like a peach except for MAC IE in which it does not work at
all and just displays a blank square no matter how many times you
refresh the page.

Here is the javascript header code:
<script language="Javascript" type="text/javascript">
<!-- Hide script from old browsers

myPix = new
Array("../web/bennertestimonial/$FILE/bennertestimonial.jpg","../web/cheungtestimonial/$FILE/cheungtestimonial.jpg","../web/ttrottestimonial/$FILE/ttrottestimonial.jpg")
imgCt = myPix.length

function choosePic() {
if (document.images) {
randomNum = Math.floor((Math.random() * imgCt))
document.myPicture.src = myPix[randomNum]
}
}

// End hiding script from old browsers -->
</script>

Here is the body onload:
onload="choosePic()"

Here is the image tag:
<img src="../web/bennertestimonial/$FILE/bennertestimonial.jpg"
width="565" height="177" alt="" border="0" name="myPicture">

I would suspect that there is something in this javascrpt code that is
not supported by the DOM on a MAC IE.

Does anyone know what that is, know what a work around would be or how
I can get this to work?

All help is appreciated.
 
A

ASM

There is this javascript reference site that I often use and I was
looking for some script that would randomly show one of three images on
page refresh.

Here is the reference site that I use:
http://www.chalcedony.com/javascript/scripts/index.html

Here is their example:
http://www.chalcedony.com/javascript/scripts/index.html

Here is the page that I built for my company's site:
http://www.otpp.com/web/website.nsf/web/newgraduates&students

This works like a peach except for MAC IE in which it does not work at
all and just displays a blank square no matter how many times you
refresh the page.

Here is the javascript header code:
<script language="Javascript" type="text/javascript">
<!-- Hide script from old browsers

myPix = new
Array("../web/bennertestimonial/$FILE/bennertestimonial.jpg","../web/cheungtestimonial/$FILE/cheungtestimonial.jpg","../web/ttrottestimonial/$FILE/ttrottestimonial.jpg")
imgCt = myPix.length

what does this $FILE in my javascript ?
function choosePic() {
if (document.images) {
randomNum = Math.floor((Math.random() * imgCt))

document.images['myPicture'].src = myPix[randomNum]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top