event.preventDefault vs. event.returnValue
On page 118 of SitePoint's "Simply JavaScript", copyright 2007, they talk a开发者_运维知识库bout how event.returnValue is used for Internet Explorer.
Q: Is that still true? IE doesn't have event.preventDefault()?
It's still true, even in Internet Explorer 9 (I just checked). But you should never use browser detection to handle these cases anyways, so just check for the presence of event.preventDefault
and set event.returnValue
to false
if it doesn't exist.
According to MSDN, IE9 supports event.preventDefault()
. event.returnValue
can be used in versions 8 and below.
Edit: I should also mention that I don't have IE9 on my bsd box, so I can't test it atm :P
精彩评论