屏蔽键盘按键
屏蔽F12
javascript 代码://只屏蔽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;
}
}
javascript 代码://按住F12空白页面或跳转其他页面
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;
}
}
禁止唤起控制台
javascript 代码:$(document).ready(function () {
document.oncontextmenu = function () {
return false;
}
//document.onselectstart = function () {
// return false;
// }
//document.oncopy = function () {
//return false;
// }
document.onkeydown = function () {
//f12
if (window.event && window.event.keyCode == 123) {
event.keyCode = 0;
event.returnValue = false;
layer.msg("别看代码了=.=")
return false;
}
//ctrl+u
if (event.ctrlKey && window.event.keyCode == 85) {
return false;
}
//ctrl+shift+i
if ((event.ctrlKey) && (event.shiftKey) && (event.keyCode == 73)) {
return false;
}
// Ctrl+S
else if ((event.ctrlKey) && (event.keyCode == 83)) {
return false;
}
};
});
禁止键盘事件
javascript 代码://禁止任何键盘敲击事件
window.onkeydown = window.onkeyup = window.onkeypress = function () {
window.event.returnValue = false;
return false;
}
屏蔽鼠标操作
禁用右键
javascript 代码://禁用右键(防止右键查看源代码)
window.oncontextmenu=function(){return false;}
javascript 代码://屏蔽右键菜单
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;
}
}
屏蔽粘贴
javascript 代码://屏蔽粘贴
document.onpaste = 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;
}
}
屏蔽复制
javascript 代码://屏蔽复制
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;
}
}
屏蔽剪切
javascript 代码://屏蔽剪切
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;
}
}
屏蔽选中
javascript 代码://屏蔽选中
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;
}
}
同时禁右键和F12
javascript 代码://禁右键和F12
document.oncontextmenu=new Function("event.returnValue=false;");
document.onkeydown=MM_KeyPress;
function MM_KeyPress(num){
var keycODe = event.keyCODe;
if(keycode ==8)
{
event.keyCode = 0;
return;
}
if(keycode >=122 && keycode <=123)
{
event.keyCode = 0 ;
event.returnValue=false;
return;
}
}
function gg(){
layer.alert(' ', {
icon: 1,
skin: 'layer-ext-moon'
})
}
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
document.onkeydown =document.onkeyup = document.onkeypress=function(){
if(window.event.keyCode == 123) {
window.event.returnValue=false;
return(false);
}
}
控制台debugger
javascript 代码:(function noDebuger(){
function testDebuger(){
var d=new Date();
debugger;
if(new Date()-d>10){
document.body.innerHTML='<div>年轻人,不要太好奇</div>';
return true;
}
return false;
}
function start(){
while(testDebuger()){
testDebuger();
}
}
if(!testDebuger()) {
window.onblur = function(){
setTimeout(function(){
start();
},500)
}
}
else{
start();
}
})();
javascript 代码://检测到打开调试跳转指定地址
(() => {
function block() {
if (
window.outerHeight - window.innerHeight > 200 ||
window.outerWidth - window.innerWidth > 200
) {
window.location = "网址";
}
setInterval(() => {
(function () {
return false;
}
["constructor"]("debugger")
["call"]());
}, 50);
}
try {
block();
} catch (err) {}
})();
javascript 代码://js检测开发者工具Devtools是否打开防调试,中断调试
setInterval(function() {
check()
}, 4000);
var check = function() {
function doCheck(a) {
if (("" + a/a)["length"] !== 1 || a % 20 === 0) {
(function() {}
["constructor"]("debugger")())
} else {
(function() {}
["constructor"]("debugger")())
}
doCheck(++a)
}
try {
doCheck(0)
} catch (err) {}
};
check();
js 代码:if(window.location.href.indexOf('#debug')==-1){
setInterval(function(){
(function (a) {return (function (a) {return (Function('Function(arguments[0]+"' + a + '")()'))})(a)})('bugger')('de', 0, 0, (0, 0));
}, 1000);
}
js 代码:function t() {
var r = "V",
n = "5",
e = "8";
function o(r) {
if (!r) return "";
for (var t = "", n = 44106, e = 0; e < r.length; e++) {
var o = r.charCodeAt(e) ^ n;
n = n * e % 256 + 2333, t += String.fromCharCode(o)
}
return t
}
try {
var a = ["r", o("갯"), "g", o("갭"), function (t) {
if (!t) return "";
for (var o = "", a = r + n + e + "7", c = 45860, f = 0; f < t.length; f++) {
var i = t.charCodeAt(f);
c = (c + 1) % a.length, i ^= a.charCodeAt(c), o += String.fromCharCode(i)
}
return o
}("@"), "b", "e", "d"].reverse().join("");
! function c(r) {
(1 !== ("" + r / r).length || 0 === r) && function () {}.constructor(a)(), c(++r)
}(0)
} catch (a) {
setTimeout(t, 100);
}
}
t();
document.onkeydown = function() {
if ((e.ctrlKey) && (e.keyCode == 83)) {
alert("CTRL + S 被管理员禁用");
return false;
}
}
document.onkeydown = function() {
var e = window.event || arguments[0];
if (e.keyCode == 123) {
alert("F12 被管理员禁用");
return false;
}
}
document.oncontextmenu = function() {
alert('右键被管理员禁用');
return false;
}