网页禁止右键,禁止F12,禁止选中,禁止复制,禁止缓存等操作

一、禁止右键

            //方法一
       document.onmousedown = function () {
if (event.button == ) {
return false;
}
}
       //方法二 
document.oncontextmenu = function () {
return false;
}

二、禁止F12

            //方法一
       document.onkeydown = function (e) {
var currentKey = , k = e || window.event;
currentKey = k.keyCode || k.which || k.charCode;
if (currentKey == ) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}
}
       //方法二
document.onkeydown = function () {
if (window.event && window.event.keyCode == ) {
window.event.returnValue = false;
}
}

三、禁止选中

            body{
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}

四、禁止复制

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

五、禁止缓存

        <meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content=""/>
上一篇:在vim下写python 会出现python错误:unexpected unident


下一篇:S 禁止F12和右键操作控制台,兼容各浏览器