Why does the onmouseover event use "return true" to prevent the default behavior?

I have been looking for this for some time, but have not received any explanation.

For "onclick" and other events in javascript, an event handler that returns false means "prevent the default action." However, there is one exception for "onmouseover". For "onmouseover," returning true means "prevent the default action."

Why is there such a strange exceptional case for "onmouseover"?

+7
javascript event-handling events onmouseover
source share
3 answers

Instead of using return false / true to prevent the default behavior, use the default method / attribute for the event object:

elem.onmouseover = function(e) { if (!e) var e = window.event; // IE if(e.preventDefault) { e.preventDefault(); } else { e.returnValue = false; // IE } } 
+6
source share

To my knowledge, returning true to prevent the link's URL from appearing in the status bar is an IE-specific (mis-) function. And trying to understand why IE is doing what it is doing is often a lost reason - just living with it ...

+3
source share

Who knows why. So it is: you return TRUE from onmouseover to prevent the url from appearing in the status bar, which would really be the default.

+2
source share

All Articles