This question already has answers here:
How to completely DISABLE any MOUSE CLICK
(5个答案)
2年前关闭。
我想隐藏游标,直到完成我的功能,但找不到如何禁用它。我的意思是我已经找到了如何隐藏和显示它,但是当它隐藏时,我仍然可以单击“如何禁用它”?
并通过Javascript以编程方式触发类
(5个答案)
2年前关闭。
我想隐藏游标,直到完成我的功能,但找不到如何禁用它。我的意思是我已经找到了如何隐藏和显示它,但是当它隐藏时,我仍然可以单击“如何禁用它”?
window.document.styleSheets[0].insertRule('* {cursor: none;}', window.document.styleSheets[0].cssRules.length);
Meteor.call("lockTheMachine", machine.nameMachine, Session.get("loggedUser"), function(err, res) {
if (!err) {
Session.set("lastMachineUsed", machine.nameMachine);
window.document.styleSheets[0].insertRule('* {cursor: default ;}', window.document.styleSheets[0].cssRules.length);
} else {
console.error(err);
}
});
}
最佳答案
有一个CSS属性称为指针事件。
CSS属性指针事件允许作者控制在什么情况下(如果有的话)特定的图形元素可以成为鼠标事件的目标。
除了指示该元素不是鼠标事件的目标之外,该值none指示鼠标事件“通过”该元素并以该元素“之下”的对象为目标。
如果要在整个网站上禁用任何点击互动,则只需添加:
body.block { pointer-events: none; }
并通过Javascript以编程方式触发类
.block
。