473,287 Members | 1,800 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,287 software developers and data experts.

Intermittent image load problem

Hi,

I have 3 small images on my page. I also have a large image which is
displayed when any of the 3 small images is clicked. I do this to display a
large version of each image. On page load the large image displays the img1
by default.

But sometimes (in IE and NS) when I click on small images, the large image
is empty and if I refresh the page it will display it. Here is my code:

function ChangeImage(Img)
{
document.getElementById("LargeImg").src =
document.getElementById(Img).src;
}

and on click event of each small image I have:

OnClick="ChangeImage('Img1')"
OnClick="ChangeImage('Img2')"
OnClick="ChangeImage('Img3')"
Why is this happening?
Thanks for your time
Regards
Mehdi
Jul 23 '05 #1
2 2080
On Sat, 21 Aug 2004 10:58:49 GMT, Mehdi <no****@nospam.nospam> wrote:
I have 3 small images on my page. I also have a large image which is
displayed when any of the 3 small images is clicked. I do this to
display a large version of each image. On page load the large image
displays the img1 by default.

But sometimes (in IE and NS) when I click on small images, the large
image is empty and if I refresh the page it will display it. Here is my
code:

function ChangeImage(Img)
{
document.getElementById("LargeImg").src =
document.getElementById(Img).src;
}

and on click event of each small image I have:

OnClick="ChangeImage('Img1')"
OnClick="ChangeImage('Img2')"
OnClick="ChangeImage('Img3')"


The code you've presented suggests that you aren't using small and large
images, but large images that have been shrunk using the height and width
attributes. If this is correct, the problem might be because the images
haven't finished loading. I couldn't really say without seeing the actual
page.

Of course, it could just be a bug. When I used IE, I noticed problems with
rollovers, but I think that it's because IE is so badly written, it wasn't
executing the correct code, or using the correct HTML[1].

What I will say though, is that it's preferable to access images using the
images collection, rather than getElementById().

function ChangeImage(img) {
document.images['LargeImg'].src = document.images[img].src;
}

Mike
[1] When I browse the Internet, I often use multiple windows (or tabs, now
I use Opera). IE seemed to confuse what data should go where and load
images from one page into another, or use images that should have been
located elsewhere on the page. I hate IE.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Thanks Mike,

I'll try image collection.

Mehdi
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Dan | last post by:
We have a fairly large set of ASP.NET applications running on Windows 2003 SP1 server. The entire suite of software was originally written in ASP and ran on a Win 2k server. For about the last...
0
by: deevoy | last post by:
Hi- I'm developing a asp.net web application and everything has proven fine on the dev and acceptance environment. We've moved the code up to our windows server 2003 prod environment and get the...
3
by: Lee Chapman | last post by:
Hi, I have a problem where my ASP.NET application occasionally generates a MissingFieldException exception. This unexpectedly happened on my development box, and so I was able to extract some...
1
by: deevoy | last post by:
Hi- I'm developing a asp.net web application and everything has proven fine on the dev and acceptance environment. We've moved the code up to our windows server 2003 prod environment and get...
0
by: Brano | last post by:
Hi all, I have a asp.net website that has been live for about 2 weeks now and there were no problems with it. I have got a new server that is Win 2003 IIS 6.0 I have moved my application onto...
3
by: Mark Szlazak | last post by:
The following page simulates a pool cue and cue ball: http://members.aol.com/myscript/cue.html Mouse cursor position around the cue ball determines where a roll-over of 179 pool cue images is...
3
by: Velvet | last post by:
I'm having an intermittent problem with IE 6.0.2900.2180.xpsp_sp2_gdr.050301-1519 installed on Windows XP. The images, style sheets and JavaScript files are not loading to the browser. ...
1
by: mfreeman | last post by:
I have a VB.NET 2005 Windows application that worked fine when I ran it a month ago, and now it is throwing an exception ("The remote server returned an error: (500) Internal Server Error.") and I...
3
by: helraizer1 | last post by:
Hey folks, yet again. if ($back == "m") //$back is a value pulled from a db; that works perfectly. { $wid = $rowing; $hei = $rowing; createthumb("660x240background2.gif", "./user/" ....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...

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.