问题描述
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
:
进一步:
此属性的值优先于函数返回的值,例如通过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
seems to be supported in IE9.
这篇关于Internet Explorer是否支持e.preventDefault的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!