473,473 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Loading images

I have recently looked at http://alistapart.com/articles/imagegallery
to implement a simple picture gallery on a webpage that I'm working on.

Everything works fine; however, I have one question. When I click on a
thumbnail, a JavaScript function is executed to change the picture in
the main view. Since some of these images are around 300KB, it takes up
to a couple of seconds to load the image. In Internet Explorer, one can
see the image loading and filling the screen. In Firefox or Opera, the
old image stays displayed until the new image is fully downloaded, and
only then the new image appears in its entirety. This is somewhat
annoying, because sometimes a new caption already appears, and the
viewer is still looking at the the old picture until the new one is
fully downloaded.

Is there anyway to do it so that also in Firefox and Opera, one will
see the new image as it is gradually loading? (as it happens if it was
loading directly from a HTML link, without using the JavaScript
function?)

Thanks,

Ivan

Aug 19 '06 #1
6 2548
For your reference, the gallery is here:
http://www.princeton.edu/~puttc/gallery.htm

If it's not possible to have Firefox and Opera "get rid" of the old
image as the new one is being loaded, would there be a way to implement
an onload event on the picture, and therefore the caption would only be
displayed once the picture is loaded?

Thanks,

Ivan

Aug 20 '06 #2

Ivan Bútora wrote:
I have recently looked at http://alistapart.com/articles/imagegallery
to implement a simple picture gallery on a webpage that I'm working on.

Everything works fine; however, I have one question. When I click on a
thumbnail, a JavaScript function is executed to change the picture in
the main view. Since some of these images are around 300KB, it takes up
to a couple of seconds to load the image. In Internet Explorer, one can
see the image loading and filling the screen. In Firefox or Opera, the
old image stays displayed until the new image is fully downloaded, and
only then the new image appears in its entirety. This is somewhat
annoying, because sometimes a new caption already appears, and the
viewer is still looking at the the old picture until the new one is
fully downloaded.

Is there anyway to do it so that also in Firefox and Opera, one will
see the new image as it is gradually loading? (as it happens if it was
loading directly from a HTML link, without using the JavaScript
function?)
If you have only a few large images, perhaps preloading them would
help. You might put some text at the top of the page to hopefully keep
the viewer busy while images are being preloaded. If you have many
large images that are likely to be selected at random, there would seem
to be little you can do. On your example page, I see no problem,
because the large images load so rapidly on clicking. However I am
using DSL broadband that downloads at over 5 Mbps from my site.

Aug 20 '06 #3

Ivan Bútora wrote:
For your reference, the gallery is here:
http://www.princeton.edu/~puttc/gallery.htm

If it's not possible to have Firefox and Opera "get rid" of the old
image as the new one is being loaded, would there be a way to implement
an onload event on the picture, and therefore the caption would only be
displayed once the picture is loaded?
It might be possible to modify code so that, when you click for a large
image, the caption of the old image is at once hidden by switching
visibility to hidden. This would require that all of the captions have
a unique id associated with each so that the clicking of the desired
image could get to the title using document.getElementById to switch
visibility from visible to hidden.

Aug 20 '06 #4
cwdjrxyz wrote:
Ivan Bútora wrote:
For your reference, the gallery is here:
http://www.princeton.edu/~puttc/gallery.htm

If it's not possible to have Firefox and Opera "get rid" of the old
image as the new one is being loaded, would there be a way to implement
an onload event on the picture, and therefore the caption would only be
displayed once the picture is loaded?

It might be possible to modify code so that, when you click for a large
image, the caption of the old image is at once hidden by switching
visibility to hidden. This would require that all of the captions have
a unique id associated with each so that the clicking of the desired
image could get to the title using document.getElementById to switch
visibility from visible to hidden.
OK, thanks - I guess I can start playing around to implement some sort
of "Please wait while the picture is loading" message in place of the
caption of the old image - I'll have to do some reading on that, since
I'm sort of learning JavaScript "on the spot".

I was just wondering why Internet Explorer seems to do this differently
from Firefox and Opera. If the latter two behaved like IE in this
particular situation, I would not have the need to put in any extra
code, because with IE, the old image disappears once the new one starts
downloading. I guess on your 5 Mbps connection none of this matters. I
have what I consider a pretty fast connection here, but some of the
larger images took up to four-five seconds to load, which is what I can
probably expect in case of people with DSL or cable connections.

Ivan

Aug 20 '06 #5

Ivan Bútora wrote:
cwdjrxyz wrote:
Ivan Bútora wrote:
For your reference, the gallery is here:
http://www.princeton.edu/~puttc/gallery.htm
>
If it's not possible to have Firefox and Opera "get rid" of the old
image as the new one is being loaded, would there be a way to implement
an onload event on the picture, and therefore the caption would only be
displayed once the picture is loaded?
It might be possible to modify code so that, when you click for a large
image, the caption of the old image is at once hidden by switching
visibility to hidden. This would require that all of the captions have
a unique id associated with each so that the clicking of the desired
image could get to the title using document.getElementById to switch
visibility from visible to hidden.

OK, thanks - I guess I can start playing around to implement some sort
of "Please wait while the picture is loading" message in place of the
caption of the old image - I'll have to do some reading on that, since
I'm sort of learning JavaScript "on the spot".

I was just wondering why Internet Explorer seems to do this differently
from Firefox and Opera. If the latter two behaved like IE in this
particular situation, I would not have the need to put in any extra
code, because with IE, the old image disappears once the new one starts
downloading. I guess on your 5 Mbps connection none of this matters. I
have what I consider a pretty fast connection here, but some of the
larger images took up to four-five seconds to load, which is what I can
probably expect in case of people with DSL or cable connections.
There is a low-tech method that has nothing to do with script that
likely could solve your problem. Make the caption part of the image.
Just take each image to PaintShop or some other like program. Enter a
background color you like and add the image. Then enter the caption
text and place it anywhere you like. Then crop to include the amount of
background area you want around the image that includes room for the
caption added. Output as jpg or any of several other formats. I can do
this simple editing very rapidly, but there is a learning curve if you
use such a program for the first time.

Aug 21 '06 #6
It might be possible to modify code so that, when you click for a large
image, the caption of the old image is at once hidden by switching
visibility to hidden. This would require that all of the captions have
a unique id associated with each so that the clicking of the desired
image could get to the title using document.getElementById to switch
visibility from visible to hidden.
I was able to write some code in the end which shows a blinking wait
message while the picture is loading, and the caption loads only after
that.

Anyway, thanks for your help.

Aug 22 '06 #7

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

Similar topics

1
by: Stacey | last post by:
Hi, I'm hoping for a bit of advise-- I have a (relatively, from the point-of-view of this dilettante) complex script that attempts to preload certain images in order to trigger one of a series of...
4
by: Adrian MacNair | last post by:
Hi, I created an image gallery which displays 63 images in a slideshow. The problem is that the show was slow because each image loaded one at a time during the show. No problem right? I just...
15
by: Geoff Cox | last post by:
Hello I have following type of code in the header function pre_load_pics() { if (document.images) { var image1 = new Image(400,265); image1.scr = "pic1.jpg";
4
by: VR | last post by:
Hi, I am trying to have a menu item (which is an HTML img) to change as a mouse moves over it. So, my code looks something like this: <a onmouseover="ActivateImage('MyImage');"...
2
by: Jean Pierre Daviau | last post by:
When I have something like this in a js file. listeImg = new Array(); listeImg = new Image(w,h); listeImg.src = "centre1.jpg"; etc Are the images loaded after the page is loaded? In the same...
0
by: speedcoder | last post by:
hi all, i'm stumped. my applet used to load images over the network. (it was actually designed by someone else.) yes, the applet used to load each image file independently over the network and...
1
by: agatha.life | last post by:
I did a javascript for the loading of images (I didn't want to have the images loaded in "on loading" because they are too many). The website is for a model and if you look at the codeof pages (...
3
jeremydowe
by: jeremydowe | last post by:
Hi, I have noticed that quite a few websites use a preloading graphic (i.e spining circle) to show the that the site is loading images while the user waits. How can I add this to my website? ...
1
by: mlikesit | last post by:
I am trying to get the following code to pre-load some images before re-dirrecting the user. The problem is that the onError event gets called for all of the images immediately. I've tripple...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.