开发者

event.preventDefault vs. event.returnValue

开发者 https://www.devze.com 2023-03-07 18:33 出处:网络
On page 118 of SitePoint\'s \"Simply JavaScript\", copyright 2007, they talk a开发者_运维知识库bout how event.returnValue is used for Internet Explorer.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号