我正在尝试禁用SharePoint 2013列表编辑页面中的超链接。我使用了内容编辑器Web部件并添加了 pointer-events: none
。在Google Chrome上可以正常工作,但在IE上无效。有没有其他的替代方式?我只想要CSS的替代方案。我的IE版本是10。
我正在尝试禁用SharePoint 2013列表编辑页面中的超链接。我使用了内容编辑器Web部件并添加了 pointer-events: none
。在Google Chrome上可以正常工作,但在IE上无效。有没有其他的替代方式?我只想要CSS的替代方案。我的IE版本是10。
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
实际上有两篇文章介绍了几种可能的方法来解决这个问题(虽然都是脚本):
其中这个答案没有使用脚本。
基于评论的更新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
pointer-event: none
?该属性应该是带有 S 结尾的pointer-events
。 - Bojangles