首页 > 技术文章 > 禁止F12与右键

empist 2017-07-15 13:47 原文

实践项目的代码哦,给大家分享下,如何屏蔽右键与F12。

 

应用网站  www.empiretreasure.vip   与       www.MineBook.vip。可以去逛逛哦。

 

不多说了,上代码。

 

<script>
    /*you can't use the F12 and right button*/
document.onkeydown = function(){
if(window.event && window.event.keyCode == 123) {
  alert("嗨~~感谢您的喜欢 \n Welcome to E'treasure \n 但是不能使用F12哦~~ \n But sorry, you can not use F12");
  event.keyCode=0;
  event.returnValue=false;
 }
}
 document.onmousedown=function(oEvent){
   if(window.event)
    oEvent=window.event;
   if(oEvent.button==2)
    alert("嗨~~感谢您的喜欢 \n Welcome to E'treasure \n 但是不能使用右键哦~~ \n But sorry, you can't use right button");}// JavaScript Document
    </script>

OK,完成啦。

 

 

(怎么感觉写过这个呢~~~~~~)

推荐阅读