How to disable the "save image as" option when right-clicking?

I want users not to right-click on the image on my site and save them. I know there is a lot of work to do, but I still need to do this.

Any help?

In addition, this site has this feature - http://finsix.com/dart/#section-colors

It can be html, javascript, jquery. Any decision will be made.

+4
source share
3 answers

Use the image as a background image of the div element, this will allow frivolous people to get rid of it;)

+10
source
$("body").on("contextmenu", "img", function(e) {
  return false;
});

"" jQuery. , , , .

+17
<script type="text/javascript">
function click (e) {
  if (!e)
    e = window.event;
  if ((e.type && e.type == "contextmenu") || (e.button && e.button == 2) || (e.which && e.which == 3)) {
    if (window.opera)
      window.alert("");
    return false;
  }
}
if (document.layers)
  document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = click;
document.oncontextmenu = click;
</script>

I found this script on selfhtml.org .

This function was originally intended to disable the context menu on the client side and to insert its own context menu. But it can also be used for this.

But keep in mind . Using browser add-ons such as NoScript, or by opening a URL, the user could get around this.

+1
source

Source: https://habr.com/ru/post/1543099/


All Articles