JavaScript——JS屏蔽F12和右键

键盘表

来源:http://www.phpweblog.net/kiyone/archive/2007/04/19/1138.html

JavaScript——JS屏蔽F12和右键

通过onkeydowm监听键盘按下事件,并修改键盘码

 //禁止F12
document.onkeydown = function () {
if (window.event && window.event.keyCode == 123) {
event.keyCode = 0;
event.returnValue = false;
}
if (window.event && window.event.keyCode == 13) {
window.event.keyCode = 505;
}
}; //屏蔽右键菜单
document.oncontextmenu = 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;
}
};
上一篇:反调试代码调试死机代码禁止F12代码


下一篇:js实现禁止右键 禁止f12 查看源代码