凌的博客

您现在的位置是:首页  > 前端学习 > Js

Js

js禁用右键点击

2016-12-26Js0
很实用的javascript: function no_right(e){ if(!document.rightClickDisabled){ if(document.layers){ document.captureEvents(Event.MOUSEDOWN); document.onmousedown = disableRightClick; }else{ document.oncontextmenu = disableRightClick; }

很实用的javascript:

function no_right(e){
	if(!document.rightClickDisabled){
		if(document.layers){
			document.captureEvents(Event.MOUSEDOWN);
			document.onmousedown = disableRightClick;
		}else{
			document.oncontextmenu = disableRightClick;
		}
		return document.rightClickDisabled = true;
	}
	
	if(document.layers || (document.getElementById && !document.all)){
		if (e.which==2||e.which==3) return false;
	}else{
		return false;
	}
}
no_right();

如果本文对您有所帮助,请支持下本站哦!!!^_^

文章评论

0条评论