896+ Capstone Project is Available: Whatsapp: +91-7011258995, Email: sharecodepoint@gmail.com

How do I disable right click (contentmenu ) to download image in JavaScript?

How do I disable right click (contentmenu ) to download image in JavaScript?

The context menu to save the image still does not appear if the user chooses to suppress alert messages from the webpage.

Works with "ALL" web browsers (including Internet Explorer 8 and above, Opera, Google Chrome, Apple Safari, and Mozilla Firefox).

  document.addEventListener("contextmenu", function(e){
    if (e.target.nodeName === "IMG") {
        e.preventDefault();
    }
}, false);
  
 window.ondragstart = function() { return false; }

Sharecodepoint

Sharecodepoint is the junction where every essential thing is shared for college students in the well-defined packets of codes. We are focused on providing you the best material package like Question papers, MCQ'S, and one NIGHT STUDY MATERIAL. facebook twitter youtube instagram

Post a Comment

Previous Post Next Post

Contact Form