网页禁用F12
网页禁用F12,禁止审查元素,屏蔽复制,禁用鼠标右键。
禁用任何键盘敲击事件(防止F12和shift+ctrl+i调起开发者工具)。
window.onload = function () {
//禁止F12
$("*").keydown(function (e) {//判断按键
e = window.event || e || e.which;
if (e.keyCode == 123) {
e.keyCode = 0;
return false;
}
});
//禁止审查元素
$(document).bind("contextmenu",function(e){
return false;
});
};
//屏蔽复制
document.oncopy = function (event){
if(window.event){
event = window.event;
}
try{
var the = event.srcElement;
if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
};
//屏蔽张贴
document.onpaste = function (event){
if(window.event){
event = window.event;
}
try{
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
//禁用Ctrl + s
window.addEventListener('keydown', function (e) {
if(e.keyCode == 83 && (navigator.platform.match('Mac') ? e.metaKey : e.ctrlKey)){
e.preventDefault();
}
});
//禁止右键
document.oncontextmenu = function(e) {alert('别看啦,宝宝好羞涩*^_^');return false;};
//禁止任何键盘敲击事件(防止F12和shift+ctrl+i调起开发者工具)
window.onkeydown = window.onkeyup = window.onkeypress = function () {
window.event.returnValue = false;
return false;
}