网页禁用右键实现代码(JavaScript代码)
时间:2024-02-26 09:46:23
<script language="javascript">
function disableRightClick(e)
{
var message = "右键禁用...";
if(!document.rightClickDisabled) // initialize
{
if(document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = disableRightClick;
}
else document.oncontextmenu = disableRightClick;
return document.rightClickDisabled = true;
}
if(document.layers || (document.getElementById && !document.all))
{
if (e.which==2||e.which==3)
{
alert(message);
return false;
}
}
else
{
alert(message);
return false;
}
}
disableRightClick();
</script>
使用方法,直接复制代码放到<head></head>中即可。
标签:网页,禁用右键
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python数据分析工具之 matplotlib详解
2023-03-11 21:53:24
![](https://img.aspxhome.com/file/2023/0/107040_0s.jpg)
使用python连接mysql数据库之pymysql模块的使用
2024-01-16 13:12:11
通俗易懂详解Python基础五种下划线作用
2024-01-01 06:36:22
![](https://img.aspxhome.com/file/2023/5/70645_0s.png)
Django中ajax发送post请求 报403错误CSRF验证失败解决方案
2021-06-11 19:47:32
![](https://img.aspxhome.com/file/2023/0/80580_0s.png)
pycharm 实现光标快速移动到括号外或行尾的操作
2023-07-17 19:52:31
树莓派4B+opencv4+python 打开摄像头的实现方法
2021-05-04 12:09:37
![](https://img.aspxhome.com/file/2023/3/91993_0s.jpg)
Python科学计算环境推荐——Anaconda
2022-12-17 15:07:30
![](https://img.aspxhome.com/file/2023/0/84990_0s.jpg)
Python Pygame实现落球游戏详解
2021-06-23 00:54:38
![](https://img.aspxhome.com/file/2023/0/94140_0s.png)
Oracle删除字段中的空格、回车及指定字符的实例代码
2024-01-18 18:10:07
pytorch 如何使用batch训练lstm网络
2023-10-18 04:46:02
![](https://img.aspxhome.com/file/2023/9/118419_0s.png)
将tensorflow模型打包成PB文件及PB文件读取方式
2022-07-02 22:47:33
详解Git.gitignore开发必备建议收藏
2022-04-29 13:44:13
Layer UI表格列日期格式化及取消自动填充日期的实现方法
2024-04-22 13:02:22
![](https://img.aspxhome.com/file/2023/8/135968_0s.png)
mysql中的sql_mode模式实例详解
2024-01-19 14:56:45
python-httpx的使用及说明
2022-11-22 15:35:18
美化段落文本 1
2008-05-15 12:24:00
![](https://img.aspxhome.com/file/UploadPic/20085/15/2008515123035529s.jpg)
Sql Server中常用的6个自定义函数分享
2024-01-17 05:05:40
在ASP.NET 中实现单点登录
2024-05-03 15:31:17
java常用正则表达式
2023-04-24 11:38:36
W3C 发布 XMLHttpRequest 工作草图
2008-04-28 13:00:00