User Tools

Site Tools


Disable the Context Menu (prevent right-click)

Pulling this one from the blog. The function and its implementation in CE3 is unchanged from CE2, nor is my stance on its use.

As a proponent of web-standards and design accessibility, disabling the web-browser's context menu – or intentionally interfering with the browser's designed functionality in any way – is something that I do not condone, nor support. I provide this function as is, only so that when people ask about it, I can point them at this page and wipe my hands of the conversation.

The notion that you can protect your images from being downloaded by using such a script is an utter fallacy; it's like hiding from monsters by closing your eyes. If you want to protect your images from illegitimate use, then your best options are either of:

  • Don't put it online.
  • Watermark the image, and embed metadata.

I like the latter option.

To say that we are “disabling” the context menu is misleading. What we actually are doing is blocking the menu, or blocking its trigger. The holy grail of web-design is that a web page should be intuitive and pleasant to use, and that it should function identically across all platforms without hindering the platform or the user. When we block the context menu, we are intentionally hindering the web-browser and disabling the visitor, working against this principle. We invite the visitor into our space, then put them into restraints. The web-browser is a tool, and we deny our users the right to use that tool as designed, and in those ways to which the visitor may be accustomed. We create a poor user experience, an experience that is counterproductive to the purpose of having a well-designed website, and an experience in which the visitor themselves is disabled and diminished.

If the argument is lost on you, then your PHPlugins function is below. Outside of what is written on this page, this function is 100% officially unsupported, and I will discuss the matter no further.

function ttg_body_bottom( $style, $path ) { 
	echo '
	$(document).ready(function() {
	    $(document).bind("contextmenu", function(e) {
	        return false;
} // END
disable_context_menu_prevent_right-click.txt · Last modified: 2013/03/24 11:58 by admin