【问题标题】:pointer-events: none not working in IE指针事件:没有在 IE 中不起作用
【发布时间】:2016-03-09 07:17:14
【问题描述】:

我正在尝试禁用我的 SharePoint 2013 列表编辑页面中的超链接。我使用了一个内容编辑器 webpart 并输入了pointer-events : none。它在 Google Chrome 上运行良好,但在 IE 中不起作用。有没有其他选择?我只想要 CSS 替代品。我的 IE 是 10 版。

【问题讨论】:

  • 这是一个错字还是你真的在你的 CSS 中输入了pointer-event: none?该属性是pointer-events,末尾有一个S
  • @Bojangles 标题拼写正确,错字已修复
  • 是的,我确实放了指针事件。抱歉这里拼错了

标签: css internet-explorer pointer-events


【解决方案1】:

pointer-events 在 IE 10 中不受支持,并且没有其他类似的 CSS 属性。

需要更改标记或使用脚本来解决这个问题。

更新

这是一个使用脚本的示例。

我还对链接进行了样式设置,因此人们无法将它们视为链接,实际上可以单独使用,基于是否有人随机单击文本并意外点击了一个,它仍然可以。

Array.prototype.slice.call(document.querySelectorAll("a")).forEach(function(link) {
  link.addEventListener("click", function(e) {  
    e.preventDefault();
  });
});
a {
  cursor: text;
  text-decoration: none;
  color: inherit;
}
Some text with <a href="http://stackoverflow.com"> a link </a> to click on

更新 2

这里实际上有 2 篇文章,其中有几种方法可以做到这一点(虽然都是脚本,但只有一个),

this answer 不使用脚本。


根据评论更新 3

要使用属性disabled='disabled',需要在服务器端添加它,使锚看起来像这样,<a href="link" disabled="disabled">Link</a>,或者使用这样的脚本在客户端添加

Array.prototype.slice.call(document.querySelectorAll("a")).forEach(function(link) {

  link.setAttribute('disabled', 'disabled');

});
/*
a {
  cursor: text;
  text-decoration: none;
  color: inherit;
}
*/
Some text with <a href="http://stackoverflow.com"> a link </a> to click on

【讨论】:

  • 你知道这个@LGSon 的任何脚本
  • @Revenant_01 用示例更新了我的答案
  • @Revenant_01 再次做了一个小更新......现在你可以接受和投票:)
  • 我尝试在我的内容编辑器 webpart 中使用该脚本,但它不起作用
  • @Revenant_01 确保脚本在你的 body 末尾或 onload/dom 就绪事件中运行。
猜你喜欢
  • 2018-02-09
  • 2023-03-06
  • 1970-01-01
  • 1970-01-01
  • 2013-06-30
  • 2011-12-30
  • 1970-01-01
  • 2021-02-15
相关资源
最近更新 更多