简体   繁体   English

在右键菜单中禁用“目标另存为”选项

[英]Disable “Save Target As” option in the right click menu

如何在Internet Explorer和Firefox浏览器的右键菜单中禁用“目标另存为”项?

You can't. 你不能

You can attempt to block the context menu entirely (which is annoying, and very very easy to bypass), but you can't do anything about individual options on it. 您可以尝试完全阻止上下文菜单(这很烦人,并且非常容易绕过),但是您不能对其中的各个选项执行任何操作。

Read this page - both for a way to disable the context menu, and the reason why you shouldn't. 阅读此页面 -既有禁用上下文菜单的方式,也有禁用该菜单的原因。 As for disabling individual menu items, that's not possible since those items are determined by the browser and kept isolated from the page itself. 至于禁用单个菜单项,这是不可能的,因为那些菜单项是由浏览器确定的,并与页面本身保持隔离。

Not possible. 不可能。 You could try blocking the context menu by adding the following to your body tag: 您可以尝试通过在body标记中添加以下内容来阻止上下文菜单:

<body oncontextmenu="return false;">

This will block all access to the context menu (not just from the right mouse button but from the keyboard as well) 这将阻止所有对上下文菜单的访问(不仅是鼠标右键,还有键盘)

There is another option for that! 还有另一种选择! You can prevent the user save your image by using the pointer-events css property: 您可以通过使用指针事件css属性来防止用户保存图像:

img {
  pointer-events: none;
}

Essentially what that's going to do is block any mouse events to img elements. 本质上,这将阻止任何鼠标事件进入img元素。 You still going to get a dialog box but that is the same you get with background images. 您仍将获得一个对话框,但与背景图像相同。

https://developer.mozilla.org/pt-BR/docs/Web/CSS/pointer-events https://css-tricks.com/almanac/properties/p/pointer-events/ https://developer.mozilla.org/pt-BR/docs/Web/CSS/pointer-events https://css-tricks.com/almanac/properties/p/pointer-events/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM