js屏蔽鼠标右键、f12,循环debugger,禁止页面内容选中
[ 2017/08/12, JavaScript , 3441阅, 0评 ]

屏蔽右键

document.oncontextmenu = function() {
	return false;
};

屏蔽f12等按键

//禁止f12(谷歌,ie有效,但仍可以从其他方式进入开发者模式)
document.onkeydown=function(e){
	var currKey=0,evt=e||window.event;
	currKey=evt.keyCode||evt.which||evt.charCode;
	if(currKey == 123){
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}
}
document.onkeydown = function () {
	var e = window.event || arguments[0];
	if (e.keyCode == 123) {
		// f12
		return false
	} else if ((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
		// ctrl+shift+i
		return false
	} else if ((e.ctrlKey) && (e.keyCode == 85)) {
		// ctrl+u查看源代码
		return false
	} else if ((e.ctrlKey) && (e.keyCode == 83)) {
		// ctrl+s另存为
		return false
	}
}

循环debugger

setInterval(function () {
	var a = String.fromCharCode(98),
		a = "d/e" + (a + "/") + "u",
		a = a + "g/g",
		a = a + "/e",
		a = a + "/r";
	eval(a.replace(/\//g, ""))
}, 100);

打开控制台后一直处于debugger模式,除非ctrl+f8禁用断点或者找出该段代码所处的位置并删除。

禁止内容选中

body{
	user-select:none;
}

相关资料

有朋自远方来...评论一下呗O(∩_∩)O