This is all basic event management, although e.preventDefault() missing ...
To break it, when you start the event handler:
- Some browsers pass a parameter for callback hold event data (this is a way to comply with standards)
- Other browsers (mostly old IEs) instead place the event data in
window.event (which is accessed here only with event , which is risky because it relies on the absence of a local variable with this name)
Next, e = e || event; e = e || event; is the standard way of saying "if this parameter has not been passed, it defaults to after || ". In this case, if the event parameter is not passed, it searches for a global variable.
e.returnValue is one of three ways to stop an event from its default action. The other two are: e.preventDefault && e.preventDefault() (which is clearly not in the code you sent), and return false;
source share