解除网页操作限制,解除右键复制等
既然我们要解除就要先看看禁止效果是如何失效的,以下代码放入网站JS里面引用即可实现效果。
// 禁止右键菜单
document.oncontextmenu = function(){ return false; };
document.oncontextmenu= new Function("event.returnValue=false");
// 禁止文字选择
document.onselectstart = function(){ return false; };
document.onselectstart = new Function("event.returnValue=false");
// 禁止复制
document.oncopy = function(){ return false; };
document.oncopy = new Function("event.returnValue=false");
// 禁止剪切
document.oncut = function(){ return false; };
document.oncopy = new Function("event.returnValue=false");
// 禁止粘贴
document.onpaste = function(){ return false; };
document.onpaste = new Function("event.returnValue=false");
// 禁止F12
document.onkeydown = function () {
if (window.event && window.event.keyCode == 123) {
event.keyCode = 0;
event.returnValue = true;
return true;
}
};
解除禁止操作
通常直接按F12,如果此键被禁止可以通过SHIFT + CTRL + I打开,或者通过浏览器菜单里面的“开发人员工具”。
选择控制台(Console),输入以下代码回车即可。
// 开启右键菜单
document.oncontextmenu = function(){ return true; };
// 开启文字选择
document.onselectstart = function(){ return true; };
// 开启复制
document.oncopy = function(){ return true; };
// 开启剪切
document.oncut = function(){ return true; };
// 开启粘贴
document.onpaste = function(){ return true; };
// 开启F12键
document.onkeydown = function () {
if (window.event && window.event.keyCode == 123) {
event.keyCode = 0;
event.returnValue = true;
return true;
}
};
图片如下