本文介绍了如何在Internet Explorer 11中使用event.detail?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在其他单击元素下,我具有防止选择元素的功能.在chrome中,函数可以正常工作,但在IE11中,e.detail不起作用.有什么用呢?如何重新组织功能代码?
I have function preventing selecting element, under other clicking element. Fumction works fine in chrome, but in IE11, e.detail doesn`t work.What use instead? How to reorganize function code?
function xorClick(e) {
if (pendingClick) {
clearTimeout(pendingClick);
pendingClick = 0;
}
switch (e.detail) {
case 1:
pendingClick = setTimeout(function() {
var parent = e.target.closest('.ui-treenode-content');
parent.click();
}, 180);
break;
case 2:
var parent = e.target.closest('.ui-treenode-content');
parent.firstChild.click();
break;
default:
break;
}
stopClick(e);
我尝试使用
var nDelta = e.detail === 0 ? e.wheelDelta : e.delta;
但是它也不起作用.
function stopClick(e) {
if (e.preventDefault) {
e.preventDefault();
} else {
e.returnValue = false;
}
e.stopPropagation();
}
<span onclick="xorClick(event)">
<div onclick="stopClick(event)">
.....
</div>
</span>
推荐答案
您可以在 IE11文档:
从我可以看到IE11和Firefox/Edge中的e.detail
之间的区别是IE11返回0,而其他返回1.也许您只需要在switch
语句中添加这种情况?
From what I can see in difference between e.detail
in IE11 and Firefox/Edge is that IE11 returns 0, but the others return 1. Maybe you just have to add that case in your switch
statement?
这篇关于如何在Internet Explorer 11中使用event.detail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!