Closed Bug 22710 Opened 25 years ago Closed 24 years ago

[DOM] onload and onerror handler of Image object don't fire

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

VERIFIED FIXED

People

(Reporter: martin.honnen, Assigned: hjtoi-bugzilla)

References

Details

(Whiteboard: [nsbeta2-][nsbeta3+])

Attachments

(5 files)

DOM level 0 client side javascript knows the
  Image
object with
  onload
and
  onerror
handlers. Both do not fire in M12.
Bugs is probably related to the same complaint about the IMG element
  http://bugzilla.mozilla.org/show_bug.cgi?id=15005


<HTML>
<HEAD>
<STYLE>

</STYLE>
<SCRIPT>
function computeImageDimensions (url) {
  var img = new Image();
  img.onload = function (evt) { alert(this.width + ':' + this.height); };
  img.onerror = function (evt) { alert(evt.type); };
  img.src = url;
}
computeImageDimensions('http://www.mozilla.org/images/mozilla-banner.gif');
computeImageDimensions('http://www.mozilla.org/images/mzilla-banner.gif');
</SCRIPT>
</HEAD>
<BODY>
<A HREF="javascript: void 0"

ONCLICK="computeImageDimensions('http://www.mozilla.org/images/mozilla-banner.gi
f'); return false;"
>
image object's dimensions
</A>
</BODY>
</HTML>
*** Bug 15005 has been marked as a duplicate of this bug. ***
Keywords: beta1
How common is this?  Why should we fix for beta1?
onload and onerror for the Image object (and the IMG element) have been around 
since js1.1/NN3. Standard application is checking for a test image on a server 
to see whether the server is up. Image preloading code which is quite common 
also often uses the onload handler.
I am not sure what the aim for beta is but I would urge you to aim to make DOM 
level 0 stuff work so that people can rely on the features they are used to.
I think it is pretty annoying when I try to use DOM level 1 stuff like changing 
the image dimensions dynamically to find out that the DOM level 0 stuff I am 
used to work with is broken.
Yeah, Its not very common. I agree to that, but I think there are some people 
who use it. And dom-0 stuff is pretty important to work because people are so 
much used to it now. 
PDT thought this was a pretty rare need, and set status to PDT-.  If we are off 
base, please add comment, and raise the issue again.
Thanks,
Jim
Whiteboard: [PDT-]
http://www.deja.com/dnquery.xp?DBS=2&ST=MS&VW=&QRY=%22img.onload%22+%7C+%22image
.onload%22&svcclass=dnserver

brings up over 100 postings on that topic (and it searches only those where 
people write img.onload or image.onload where people might use arbritrary other 
variable names)

This is an important issue, but I'll live with the PDT- designation. This is 
high on the M15 fix list.
Status: NEW → ASSIGNED
Target Milestone: M15
I don't think this is quite as rare as thought.    Any site using the Webcam32 
video streaming software relies on this.     
Check out:  bug 17067

A google search on "webcam32" comes up with 3,229 hits, BTW.
Unfortunately this didn't make into M15, trying for M16
Target Milestone: M15 → M16
Adding nsbeta2 to keywords.
Keywords: nsbeta2
Whiteboard: [PDT-]
Whiteboard: [nsbeta2+][6/01]
Putting on [nsbeta2+][6/01] radar.  This work must be done by 06/01 or we may 
pull this for PR2.
I do not believe this is a platform-specific item.

-WD
OS: Windows 98 → All
Tom, I think you're the man for this bug!
Assignee: vidur → joki
Status: ASSIGNED → NEW
Changing from [6/01] to [6/15]
Whiteboard: [nsbeta2+][6/01] → [nsbeta2+][6/15]
Cleaning up status whiteboard by marking beta2 minus (6/15 has passed)

This sounds like a signiicant item for compatability with existing sites. Unless 
this is already fixed, please think about nominating for beta3, or filing a 
help-wanted on mozilla.
Whiteboard: [nsbeta2+][6/15] → [nsbeta2-]
M16 has been out for a while now, these bugs target milestones need to be 
updated.
Adding [DOM] prefix to bugs related to DOM Level 0, 1, or 2 
compatibility/compliance.
Status: NEW → ASSIGNED
Summary: onload and onerror handler of Image object don't fire → [DOM] onload and onerror handler of Image object don't fire
Updating Milestone to M18.
Target Milestone: M16 → M18
Nominating for nsbeta3. It seems important enough to me.
Keywords: nsbeta3
onload is an important property, very often used whenever preloading images.  
I just noticed this on build 2000080104 under MacOS 8.6, while developing an 
actual application that needs it (although setInterval checking Image.complete is 
a cumbersome alternative).  Changing Platform to All.

Here's a one-or-two-line test case:
<IMG SRC="http://mozilla.org/images/mozilla-banner.gif"
  onload="alert('Loaded.')">
Hardware: PC → All
Attached file One-line test case
Unfortunately, image.complete doesn't trigger either ! 
On www.bestmat.be/en/service.html 
body onload="ldbig()" doesn't change "arrow" image; timer01 never ends... 

var curpict= "../jpegs/atelier";
var arrow_1= new Image(); arrow_1.src= "../gifs/arrow_1.gif";
var max= new Image(), timer01= null; 
function dspl(){ 
	if(max.complete && document.images["arrow"]){ 
		document.images["arrow"].src= arrow_1.src; 
		clearInterval(timer01)} 
} 
function ldbig(){max.src= curpict +"b.jpg"; timer01= setInterval("dspl()",100)}
I am the virtual joki.
Assignee: joki → heikki
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Per discusion with Nisheeth, marking nsbeta3+. Will email ekrock to verify.
Whiteboard: [nsbeta2-] → [nsbeta2-][nsbeta3+]
Priority: P3 → P2
Not only 'onload' event doesn't fire when image loaded :   
complete, width and height properties aren't updated either.  
Once bug 28277 is fixed this should be easier to fix, the problem right now is
that the HTMLImageElement doesn't register a callback to the image loader and
thus it never knows when the image has loaded. Once a callback is in place the
fireing of the events could be added to the same callback...
Depends on: 28277
*** Bug 50713 has been marked as a duplicate of this bug. ***
PDT agrees P2
Keywords: review
Whiteboard: [nsbeta2-][nsbeta3+] → [nsbeta2-][nsbeta3+][fixinhand]
*** Bug 46046 has been marked as a duplicate of this bug. ***
Fix checked in.

Please note that there are at least some open problems still, but they are not 
covered by this bug. Namely, the load event for the document load can fire 
before the image load. Also, you can have several alert dialogs open.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Keywords: review
Resolution: --- → FIXED
Whiteboard: [nsbeta2-][nsbeta3+][fixinhand] → [nsbeta2-][nsbeta3+]
Verified with 2000-091309. Marking verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: