Skip to content

Instantly share code, notes, and snippets.

@jacurtis
Last active November 25, 2019 18:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacurtis/48f8834cd19f80bd8108843d2fa32c39 to your computer and use it in GitHub Desktop.
Save jacurtis/48f8834cd19f80bd8108843d2fa32c39 to your computer and use it in GitHub Desktop.
Removes right-click on images
/*
* 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