网页js代码禁止屏蔽右键菜单屏蔽复制屏蔽剪切屏蔽选中

放到全局JS里即可

//屏蔽右键菜单
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; 
	} 
}


//屏蔽复制
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.oncut = 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;
	}
}

 //按键触发
document.onkeydown = function(){
//禁止 F12
if (window.event && window.event.keyCode == 123) {
event.keyCode = 0;
event.returnValue = false;
}
}

//禁止ctrl+s
if (event.ctrlKey && window.event.keyCode==83){
return false;
}
}

 //禁止 F5 
if (window.event && window.event.keyCode == 116) {
event.keyCode = 0;
event.returnValue = false;
}
}

图片[1]-网页js代码禁止屏蔽右键菜单屏蔽复制屏蔽剪切屏蔽选中-HostJL-VPS主机交流

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片