Suppress right-click menu on a web site
May 30, 2009 2:50 AM   Subscribe

Is there a way to disable the right-click menu on a particular web page I visit that isn't managed by me?

I play a solitaire game on a particular web site fairly often. It's not a Flash game, nor is it a Java applet, I suspect it's simply JavaScript.

The game allows you to use both left and right clicks, each performing different actions, but every time you right-click the normal browser right-click menu appears...very annoying in this context.

Is there a way for me to tell my browser I don't want the right-click menu to appear on this one particular page (or its domain, if that's easier)? I have greasemonkey installed, so a GM script would be ideal, but I haven't been able to locate one.

I'm on Windows, using FF. Thanks mucho for any ideas. (I could possibly write my own script if pointed in the right direction.)
posted by maxwelton to Computers & Internet (3 answers total)
 
An easy way for you to do it would be to make a toolbar bookmark with
javascript:void(document.oncontextmenu=new%20Function("return%20false"))
in it. When you click on it up in your toolbar right clicking should be disabled for the page.

Took me way longer to figure that out than it should have; I am apparently way too rusty with these things.

posted by Stunt at 3:51 AM on May 30, 2009 [1 favorite]


Best answer: For Greasemonkey

if(document.addEventListener)
document.addEventListener('contextmenu', function(e) { e.stopPropagation(); }, false);
else if(document.attachEvent)
document.attachEvent('oncontextmenu', function() { event.cancelBubble = true; });

Set up a new user script and apply it to the appropriate domain, then copy and paste the above in.
posted by Sparx at 4:19 AM on May 30, 2009


Response by poster: Thanks! I was able to get Sparx solution to work a treat, but I could not get Stunt's to work, which may be more me than their solution.
posted by maxwelton at 11:04 AM on May 30, 2009


« Older What is a gel that turns to liquid with minor...   |   What European country will offer the lowest price... Newer »
This thread is closed to new comments.