PDA

View Full Version : preloading breaks script in Opera



jscheuer1
12-15-2006, 08:49 PM
Why in the world would the second slide show on this page:

http://home.comcast.net/~jscheuer1/side/files/interactive_slide_oo_opera_no.htm

not cycle past the the first image the second time around in Opera 9.01? The only crucial difference between it and the first slideshow is that its images are preloaded.

I tried preloading them various ways - inside the script, outside the script - with the preloaded image object's source as the source for the image tag and without that. The only preloading method that didn't cause this problem was to write out a division with display:none; and put the images in it.

Preloading the images any of these ways presents no problem in IE 7 or FF 1.5.0.8 and causes no reported errors in either of those or in the Opera browser.

:confused:

mwinter
12-16-2006, 03:21 AM
Why in the world would the second slide show on this page:

http://home.comcast.net/~jscheuer1/side/files/interactive_slide_oo_opera_no.htm

not cycle past the the first image the second time around in Opera 9.01? The only crucial difference between it and the first slideshow is that its images are preloaded.

By preloading the images, you only cause the load event for the img element to be fired once for each image, therefore the procession stops.

Mike

jscheuer1
12-16-2006, 05:43 AM
By preloading the images, you only cause the load event for the img element to be fired once for each image, therefore the procession stops.

Mike

Seems like a bug in Opera then. You are absolutely right though. What I don't get is, if the images are preloaded, why does it even go through once? And, as I said, this is not a problem in IE 7 or FF 1.5.0.8. Do you think those browsers have it wrong? It is the onload event of the tag, not of the images themselves that should be firing. Anyways, thank you. This tidbit has led me to abandon preloading for this script altogether and move some of the code around to take more appropriate advantage of the image's onload event to synchronize other (the text) updates in the show to the image's actually being loaded (actually visible to the user).

Here's the fixed up version:

http://home.comcast.net/~jscheuer1/side/files/interactive_slide_oo_o_fixed.htm

mwinter
12-16-2006, 04:27 PM
Seems like a bug in Opera then.

Perhaps. It's certainly unintuitive. You can always ask on a Opera newsgroup (Opera Software has its own public NNTP server).



What I don't get is, if the images are preloaded, why does it even go through once?

It seems that it might just be luck. I ran a simple test that didn't start changing the source of an element until all of the images (all two :)) had been preloaded. The event only fired once when the initial assignment occurred, and never again.

In your test page, if all of the images manage to be loaded before the procession can begin, it should fail even sooner.



And, as I said, this is not a problem in IE 7 or FF 1.5.0.8. Do you think those browsers have it wrong?

There's no formal definition for the load event on images in either the HTML Specification or DOM Events Level 2, so you'd have to pick a "right" before anything can be labelled "wrong".

Mike

jscheuer1
12-16-2006, 05:19 PM
There's no formal definition for the load event on images in either the HTML Specification or DOM Events Level 2, so you'd have to pick a "right" before anything can be labelled "wrong".

Mike

That's it then. I've lurked in enough Opera oriented forums to understand that 'Opera purists' (I think there are such folks) seem to prefer their browser to be minimalist when it comes to firing events or doing anything via javascript, as long as at the same time it adheres to the technical specifications. If there is no specification, then this is most likely how they'd want it to behave.

After your revelation though, I realized that this behavior pointed to a way of using this to good advantage. If preloading is inconsistent across browsers in this setup, removing it and shifting how the onload event of the image tag is used creates an effect similar to more complex code that incrementally preloads slide show images.