1、右键无任何反应
第一种
document.oncontextmenu = new Function("return false;");
第二种
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; } }2.弹窗提示并变成空白页
document.onmousedown = function mdClick(event) { var e = event || window.event || arguments.callee.caller.arguments[0]; if (e.button == 2 || e.button == 3) { alert("呵呵"); //不建议用以下方法,易错率大 window.location = 'about: blank'; } }
禁止元素审查
1. 按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; } if(window.event && window.event.keyCode == 8) { alert(str+"\n请使用Del键进行字符的删除操作!"); window.event.returnValue=false; } }2.按F12弹窗提示
document.onkeydown = function(){ if(window.event && window.event.keyCode == 123) { alert("F12被禁用"); event.keyCode=0; event.returnValue=false; } if(window.event && window.event.keyCode == 13) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 8) { alert(str+"\n请使用Del键进行字符的删除操作!"); window.event.returnValue=false; } }按F12空白页
第一种
function mAlert() { var fn = function () {}; fn.toString = function () { window.location = 'about: blank'; console.log("呵呵"); } console.log("%c", fn);//请不要删除这行 };mAlert();第二种
document.onkeydown = function(){ if(window.event && window.event.keyCode == 123) { window.location="about:blank"; //将当前窗口跳转置空白页 event.keyCode=0; event.returnValue=false; } if(window.event && window.event.keyCode == 13) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 8) { alert(str+"\n请使用Del键进行字符的删除操作!"); window.event.returnValue=false; } }
按F12关闭当前窗口
document.onkeydown = function(){ if(window.event && window.event.keyCode == 123) { window.close(); //关闭当前窗口(防抽) event.keyCode=0; event.returnValue=false; } if(window.event && window.event.keyCode == 13) { window.event.keyCode = 505; } if(window.event && window.event.keyCode == 8) { alert(str+"\n请使用Del键进行字符的删除操作!"); window.event.returnValue=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.onselectstart = 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网页另存为
document.onkeydown = function(){ //禁止ctrl+s if (event.ctrlKey && window.event.keyCode==83){ return false; } }
发表评论