您的位置:首页 > Web前端 > JQuery

网页右键、复制、另存为、缓存等功能的禁用以及F12禁用

2016-10-28 09:41 465 查看
1、右键禁用

方法1:

document.oncontextmenu = function () {
return false;
}
方法2:

document.onmousedown = function () {
if (event.button == 2) {
return false;
}
}


2、复制禁用

<script>
function noCopy()
{
event.returnValue = false;
}
</script>
<body oncopy = "noCopy()">


3、另存为禁用

在<body>内容主体中加入<noscript><iframe src='*.html'></iframe></noscript>

4、缓存禁用

<head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
</head>


5、F12禁用

方法1:

document.onkeydown = function (e) {
var currentKey = 0, k = e || window.event;
currentKey = k.keyCode || k.which || k.charCode;
if (currentKey == 123) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}
}

方法2:

document.onkeydown = function () {
if (window.event && window.event.keyCode == 123) {
window.event.returnValue = false;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jquery .net