Internet Explorer是否支持e.preventDefault [英] does internet explorer supports e.preventDefault

查看:144
本文介绍了Internet Explorer是否支持e.preventDefault的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Internet Explorer是否在javascript中不支持 e.preventDefault ?如果不是什么原因和替代方案是什么?请不要建议使用jQuery,mootools等库的任何解决方案。

Does internet explorer does not support e.preventDefault in javascript? If not what is the reason and what are the alternatives? Please do not suggest any solutions with libraries like jQuery, mootools, etc.

if (!e) e = window.event;

if (e.preventDefault) { 
    e.preventDefault(); 
} else {
    e.returnValue = false;
}


推荐答案

好的,如果你坚持:

event.preventDefault 不起作用,因为它在IE中不存在。

event.preventDefault does not work, because it does not exist in IE.

由于它不存在的原因,人们必须为MS工作。但总的来说,IE并不总是符合标准。

For the reason why it does not exist, one would have to work for MS. But in general, IE is not always conform to the standards.

文档说你可以设置 event.returnValue


false

取消源对象上事件的默认操作。

false
Default action of the event on the source object is canceled.

进一步:


备注

Remarks

此属性的值优先于函数返回的值,例如通过Microsoft JScript返回语句。

The value of this property takes precedence over values returned by the function, such as through a Microsoft JScript return statement.

标准信息

此属性没有适用的公共标准。

There is no public standard that applies to this property.

preventDefault IE9似乎支持。

preventDefault seems to be supported in IE9.

这篇关于Internet Explorer是否支持e.preventDefault的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆