Ticket #1925 (closed bug: fixed)
error with $(window).load in safari 2.0
| Reported by: | eric | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.2 |
| Component: | event | Version: | 1.2.1 |
| Keywords: | safari, event, window, load | Cc: | |
| Blocking: | Blocked by: |
Description
In Safari version 2.0 $(window).load fails with error 'undefined value'. For anyone testing this, Safari version 2.0.4 does _not_ have this bug, not sure about the other 2.0.x versions.
Attachments
Change History
comment:1 Changed 6 years ago by eric
As a test case, try:
$(window).load(function(){
$('#output').append('<p>load</p>');
});
In Safari 2.0 event.target is null for window load events. Since other code in assumes there is an event.target, the code gives an undefined error. The patch modifies the fix function in event.js to provide the document object as a fallback for event.target, which conforms to what later versions of Safari do.
comment:2 Changed 6 years ago by brandon
- Priority changed from critical to major
Fixed in Rev [3825]
comment:4 Changed 20 months ago by rwaldron
EDIT: Removing this patch will cause IE6,7,8 to crash
This bug no longer exists in jQuery supported versions of Safari. if there is any issues or unforseen regressions, the code used to correct this was:
// Fix target property, if necessary
if ( !event.target ) {
// Fixes #1925 where srcElement might not be defined either
event.target = event.srcElement || document;
}
in jQuery.event.fix()
This was discovered while implementing #8789
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

