By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,567 Members | 1,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,567 IT Pros & Developers. It's quick & easy.

Displaying a random image

P: n/a
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/...uates&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.

Sep 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
ASM
ro*********@gmail.com wrote:
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/...uates&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]
}
}

// 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.

--
Stephane Moriaux et son [moins] vieux Mac
Sep 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.