How to completely DISABLE any MOUSE CLICK(如何完全禁用任何鼠标单击)
问题描述
在用户点击......登录"按钮和其他事件后,我制作了一个加载脚本 - 让用户知道他们必须等待(直到 ajax 回复).
After the user clicks on...."log in" button, and other events, I made a loading script -to let users know they have to wait (Until ajax replies back).
如何禁用 div id="doc"
上的任何鼠标点击(右键单击、左键单击、双击、中键单击、x 单击)?
我想将该代码添加到 loading.js
How can I DISABLE any MOUSE CLICKS (right click, left click, double click, middle click, x click), on div id="doc"
?
I want to add that code to loading.js
HTML
<html>
...
<body>
<div id="doc">
<div id="content">
...
<input type="button" value="Login" id="login" />
...
</div id="content">
</div id="doc">
</body>
</html>
loading.js
function load_bar(x)
{
if (x==0)
{
$(document.body).css( {"cursor": "default"} );
$("body").css( {"cursor": "default"} );
$("#loading").css("visibility", "hidden"); //modal window
// $("#doc").....ENABLE all clicks (left/right/etc)
}
else if (x==1)
{
$(document.body).css( {"cursor": "wait"} );
$("body").css( {"cursor": "wait"} );
$("#loading").css( {"visibility": "visible"} ); //modal window
// $("#doc").....DISABLE all clicks (left/right/etc)
}
else
{
return alert("Wrong argument!");
}
}
jQuery
$(document).ready(function()
{
//AJAX
$("#login").click(function()
{
load_bar(1); //DISABLE clicks and show load_bar
$(":input").attr("disabled", true);
$.post(
...
function(data)
{
...
load_bar(0); //ENABLE clicks and hide load_bar
...
} //END: if:else
}); //END:$.post
...
}); //END:ajax
}); //END:jQuery
推荐答案
你可以覆盖一个大的、半透明的 <div>
来接受所有的点击.只需使用以下样式将新的 <div>
附加到 <body>
:
You can overlay a big, semi-transparent <div>
that takes all the clicks. Just append a new <div>
to <body>
with this style:
.overlay {
background-color: rgba(1, 1, 1, 0.7);
bottom: 0;
left: 0;
position: fixed;
right: 0;
top: 0;
}
这篇关于如何完全禁用任何鼠标单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何完全禁用任何鼠标单击


- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 400或500级别的HTTP响应 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01