Is it possible to remove “Inspect Element”?

后端 未结 9 1159
予麋鹿
予麋鹿 2020-12-05 01:10

Is it possible to remove or disable \"Inspect Element\" context menu in Chrome App via Javascript?

I have searched through several forums but there are no definite a

9条回答
  •  感情败类
    2020-12-05 01:39

    You can't.

    Everything on a web page is rendered by the browser, and they want web sites to properly work on them or their users would despise them. As a result, browsers want to expose the lower level ticks of everything to the web developers with tools like code inspectors.

    You could try to prevent the user from entering the menu with a key event. Something like this:

    // Disable inspect element
    $(document).bind("contextmenu",function(e) {
      e.preventDefault();
    });
    $(document).keydown(function(e){
      if(e.which === 123){
        return false;
    }
    });
    

    But if a user want to see the code, he will do it in another way. He will just need a little longer.

    Short: If you do not want people to get something in their browser, you shouldn't send it to their browser in the first place.

提交回复
热议问题