CSS指针事件IE10和IE11旧版本

时间:2018-09-25 09:43:21

标签: css internet-explorer-10

#values43011009create {
    pointer-events: none;
    background-color: #f9f9f9;
}

此代码在IE 10中不起作用,但在IE 11及更高版本中可以正常工作。

我也需要修复较低版本的IE。感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

对此的另一种解决方案是在链接顶部添加一个Psuedo ::after元素作为封面,防止其被点击:

.yourlink {
    position: relative;
    z-index: -1
}

.yourlink::after {
    content: ' ';
    background-color: #fff;
    position: absolute;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    width: 100%;
    z-index: 250; 
}

如果您只想在IE浏览器而不是Firefox或Chrome上执行此操作,则可以将所有这些都包装在仅针对IE的媒体查询中:

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .yourlink {
        position: relative;
        z-index: -1
    }

    .yourlink::after {
        content: ' ';
        background-color: #fff;
        position: absolute;
        height: 100%;
        top: 0;
        left: 0;
        opacity: 0;
        width: 100%;
        z-index: 250; 
    }
}

以下是解决方案的一个例子:https://jsfiddle.net/Ly06krt3/23/

答案 1 :(得分:0)

为防止点击事件,您可以参考以下示例。

var handler = function(e)
{
    e = e || window.event;
    var target = e.target || e.srcElement;
    if (target.tagName.toLowerCase() === 'a')
    {
        if (!e.preventDefault)
        {//IE quirks
            e.returnValue = false;
            e.cancelBubble = true;
        }
        e.preventDefault();
        e.stopPropagation();
    }
};
if (window.addEventListener)
    window.addEventListener('click', handler, false);
else
    window.attachEvent('onclick', handler);

参考:

“pointer-events: none” does not work in IE9 and IE10