不一定完全有效,但可以防止大部分用户[滑稽]
禁用右键菜单
▪第一种: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;
}
}
禁止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; }}▪第二种(这个是有弹窗提示的):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; }}▪第三种(这个是变成空白页):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;
}
}
原文地址:https://fendou.gqr5.cn/4107.html
暂无评论内容