Ticket #42 (closed bug: fixed)
hover: mouseout function not working in Safari
| Reported by: | tfs7 AT excite DOT c | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0 |
| Component: | event | Version: | 1.0 |
| Keywords: | hover | Cc: | |
| Blocking: | Blocked by: |
Description
Here is the function I have for doing a simple image rollover (for AJAX actions taking place on click that ultimately "deadens" the clicked link). Pre-1.0 versions of jQuery worked in Safari properly, but 1.0a has the mouseout function not working. FF mac, FF, and IE all work appropriately. (Related note: I've had some problems with toggle() at times in Safari at times with older versions of jQuery, which might help the debugging.)
$(foo).hover(function(){ var s = $(this).get(0).getAttribute("src"); if(s == "/images/up.gif")
$(this).set("src","/images/up_roll.gif");
},function(){ var s = $(this).get(0).getAttribute("src"); if(s == "/images/up_roll.gif")
$(this).set("src","/images/up.gif");
});
Attachments
Change History
Changed 7 years ago by adrian@…
-
attachment
jquery-safari-hover.diff
added
patch to jQuery 1.0a fixes bug (tested in Safari 2.0.4 and Firefox 1.5.0.4)
Changed 7 years ago by adrian@…
-
attachment
jquery-safari-hover.2.diff
added
patch to jQuery 1.0a fixes bug under Safari (tested in Safari 2.0.4 and Firefox 1.5.0.4)
comment:3 Changed 7 years ago by Adrian Samps
This somewhat awkward patch fixes the bug under Safari. I've tested it with Safari 2.0.4 and Firefox 1.5.0.4.
--- jquery-1.0a.js 2006-07-01 07:15:52.000000000 -0700
+++ jquery-1.0a-fixed.js 2006-07-08 18:23:16.000000000 -0700
@@ -878,7 +878,10 @@
// A private function for haandling mouse 'hovering'
function handleHover(e) {
// Check if mouse(over|out) are still within the same parent element
- var p = e.fromElement || e.toElement || e.relatedTarget;
+ if (e.type == "mouseover")
+ var p = e.fromElement || e.relatedTarget;
+ else
+ var p = e.toElement || e.relatedTarget;
while ( p && p != this ) p = p.parentNode;
// If we actually just moused on to a sub-element, ignore it
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Mouseover and mouseout on IE for same function above does not now either.