JavaScript
Article

jQuery Disable Right Mouse Click

By Sam Deering

jQuery Code Snippet to disable the mouse right click as often used with websites who want to add some low level security. jQuery can do this with a bind to the contextmenu event. I reccommend only using this function if you have to as it is generally bad practice.

$(function() {
	$(this).bind("contextmenu", function(e) {
		e.preventDefault();
	});
});
Sam Deering
Meet the author
Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.
  • Pete Sake

    good job! thanks!

  • skoda

    Thank you so much Sam…..

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in JavaScript, once a week, for free.