Last active
November 25, 2019 18:08
-
-
Save jacurtis/48f8834cd19f80bd8108843d2fa32c39 to your computer and use it in GitHub Desktop.
Removes right-click on images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This script will look for all images on a page and prevent right clicking on an image. | |
*/ | |
const images = document.getElementsByTagName('img'); | |
for(var i = 0; i < images.length; i++) { | |
images[i].addEventListener('contextmenu', event => event.preventDefault()); | |
} | |
// Note: I threw this script together as requested by a subscriber. I personally don't recommend doing | |
// this in a project because it is just annoying for users. With great power comes great responsibility. | |
// Just because you CAN do something, doesn't mean you SHOULD. But this is how you would do it if | |
// you felt it was necessary. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment