是否有可能删除“检查元素”? [英] Is it possible to remove "Inspect Element"?

查看:107
本文介绍了是否有可能删除“检查元素”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过Javascript在Chrome应用程序中删除或禁用Inspect Element上下文菜单?



我已经搜索了几个论坛,但没有明确的答案。

解决方案

可以通过右键点击(javascript)来阻止用户打开上下文菜单:



$ p $ document.addEventListener('contextmenu',function(e){
e.preventDefault();
});

通过监听 contextmenu 事件并防止默认行为是显示菜单,菜单将不会显示。
但用户仍然可以通过控制台检查代码(例如,在Chrome中按F12)。


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 answer.

解决方案

It is possible to prevent the user from opening the context menu by right clicking like this (javascript):

document.addEventListener('contextmenu', function(e) {
  e.preventDefault();
});

By listening to the contextmenu event and preventing the default behavior which is "showing the menu", the menu won't be shown. But the user will still be able to inspect code through the console (by pressing F12 in Chrome for example).

这篇关于是否有可能删除“检查元素”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆