-
-
Save azimidev/392045f9b31dd769eebf3ae0662e034b 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