分享六个防止网站被扒的小代码
①:电脑右键无反应document.oncontextmenu = new Function("return false;");
②:F12审查元素,F12键无反应 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; }
③:拦截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; }}
④:禁止选中该站内容
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;}}
⑤禁止复制该站内容
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;}}
⑥:禁止使用Ctrl+S另存
document.onkeydown = function(){ //禁止ctrl+s if (event.ctrlKey && window.event.keyCode==83){ return false; } }
谢谢你
页:
[1]