[thelist] Preventing right-clicking on a page?

Bob Haroche spambait at onpointsolutions.com
Mon Oct 14 10:38:01 CDT 2002

I agree with all the others about not disabling the right click. One
additional reason is that, if I were the client and came across that script,
I'd think you don't trust me -- which of course you don't. Perhaps not the
best way to manage client relations.

Nonetheless, since you asked here's a sample javascript for you:

var message="Sorry, right clicking is disabled.";
function click(e){
if(event.button==2||event.button==3){alert(message);return false;}}
if(document.layers){if(e.which==3){alert(message);return false;}}}

Perhaps a better way to implement the disabling is to install a "useful"
right click widget as was done at http://spider-food.net. I personally think
that widget is a *bad* thing because it confounds user's expectations and
deprives them of normal functionality but in this case it might alleviate
the appearance that you're simply doing this out of lack of trust.

Bob Haroche
O n P o i n t  S o l u t i o n s

More information about the thelist mailing list