如何在Internet Explorer 11中使用event.detail? [英] How to work with event.detail in Internet Explorer 11?

查看:223
本文介绍了如何在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>


推荐答案

您可以在

注意从Internet Explorer 11开始,此事件会触发 MSPointerEvent对象,而不是MouseEvent.您可以使用 MouseEvent.pointerType属性来确定该联系人的类型 点击来自(触摸,鼠标或笔).

Note Starting with Internet Explorer 11, this event fires a MSPointerEvent object instead of MouseEvent. You can use the MouseEvent.pointerType property to determine the type of contact that the click originated from (touch, mouse, or pen).

从我可以看到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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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