Skip to content Skip to sidebar Skip to footer

Jquery Preventdefault And Ie8 Clarification

I have been trying to understand why sometimes IE8 doesn't like PreventDefault and why sometimes it seems to be OK (no errors). From what I have read, including here at SO is that

Solution 1:

Yes, your understanding sounds correct. Also, if you're using a "DOM0" event handler (e.g. someElement.onclick = function(e) { ... }), there is a simpler way to prevent the browser default behaviour that works in all browsers that support events: return false.

var someElement = document.getElementById("someElementId");
someElement.onclick = function(e) {
    // Do some stuffreturnfalse;
};

However, in this case, the event is not passed to the event handler in IE <= 8 and you have to get it from window.event instead.

Post a Comment for "Jquery Preventdefault And Ie8 Clarification"