Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Displaying a random image

Reply
Thread Tools

Displaying a random image

 
 
robbiehenry@gmail.com
Guest
Posts: n/a
 
      09-19-2005
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.

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      09-19-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
Random Image Script for more than one image slot Linda Javascript 5 01-07-2005 06:01 PM
Displaying image after selecting an image file. http://www.visual-basic-data-mining.net/forum ASP .Net 0 09-15-2004 01:36 PM
Random NOt random? Darren Clark ASP .Net 3 06-24-2004 05:23 PM



Advertisments