473,385 Members | 1,409 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,385 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 2087
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/" ....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.