473,326 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Displaying a random image

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
1 1639
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: bhennon | last post by:
Hey all, I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to...
2
by: Ken Varn | last post by:
I have a control that I developed that uses a custom HTTPModule to dynamically render images to a web page using ASP.NET. It works most of the time with one exception. For some reason, Internet...
6
by: comp.lang.php | last post by:
/** * Generate the random security image * * @access public * @param $willUseFilePath (default false) boolean to determine if you will be using a file path * @param mixed $filePath (optional)...
12
by: Jim Michaels | last post by:
I need to generate 2 random numbers in rapid sequence from either PHP or mysql. I have not been able to do either. I get the same number back several times from PHP's mt_rand() and from mysql's...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
4
by: Kim | last post by:
Random image downloader for specified newsgroup. Hi I'm writing a small script that will download random images from a specified newsgroup. I've imported yenc into the script but I can't open the...
3
by: Blasting Cap | last post by:
On a web page (the default page of my app), I want to grab some shots off another of our websites (pictures of products that are already thumbnailed) for display on my page. I've found some...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
0
by: readnlearn | last post by:
hai, i have written this below code for displaying captcha image whenever i entered incorrect uname,password in login page. for that i disable the controls of captcha like textbox,labels,button and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.