JS禁止查看网页源代码的实现方法

先给大家分享下三种查看路径的方法:

1、直接按F12

2、Ctrl+Shift+I查看

3、鼠标点击右键查看

把以上三种状态都屏蔽掉就可以了,document有onkeydown(键盘按键事件),该事件里面找到对应的keycode并处理就可以,document也有oncontextmenu鼠标右键事件,屏蔽即可。


window.onload=function(){
document.onkeydown=function(){
var e=window.event||arguments[0];
if(e.keyCode==123){
alert("小样你想干嘛?");
return false;
}else if((e.ctrlKey)&&(e.shiftKey)&&(e.keyCode==73)){
alert("还是不给你看。。");
return false;
}
};
document.oncontextmenu=function(){
alert("小样不给你看");
return false;
}
}
原文地址:http://www.jb51.net/article/94568.htm

猜你喜欢

转载自blog.csdn.net/xx123698/article/details/58592322
今日推荐