enavu webdevmania tutsvalley psdestination
visit the enavu network
8 Comments Article Title Overlay Article Title

Disabling right mouse click menu with jQuery

There are few reasons why you would want to disable the menu we get after clicking right mouse button. One of them is if you want to show your own menu. In this daily tip we will disable that default menu using jQuery.

DZoneDiggDesign FloatDeliciousBlinklistRedditFacebookGoogle BuzzTwitterStumbleUponTumblrShare

Demo     Source

$(document).ready(function() {

     //this one line will disable the right mouse click menu
     $(document)[0].oncontextmenu = function() {return false;}

});

It’s that easy :)

Related posts:

  1. 10 Awesome jQuery and JavaScript Snippets
  2. Easy Unobstructive jQuery Print Page Tutorial
  3. Description text inside an input field
  4. Hover effect with jQuery and CSS
  5. Sliding door effect with JQuery

Slobodan Kustrimovic

This author has yet to fill his BIO.

Did you absolutely LOVE this article... share it!

Comments

  • Unfortunately this script and all scripts for disable context menu don’t work with Opera :(

  • $(function(){
    $().bind(“contextmenu”,function(){return !1;});
    });

    For Opera users, you have to enable the “Allow scripts to detect context menu events” in “JavaScript Options”. This options excist for all modern browsers.

  • Who uses Opera? Seems like a lot of basic dom objects that everyone else supports, aren’t supported in opera. Whats up with that? I am wondering who uses Opera, is it developers? All the devs I know use Firefox with firebug. What is the advantage to using Opera? Seems like the only time I ever here about Opera is when someone leaves a comment under some piece of basic code that says…duuude yer thing doesnt work in Opera….It works in IE6, IE7, IE8, Safari, and FF2, FF3 but not Opera…please someone tell me whats the deal with it.
    :-)

  • @Simone – jerone has submitted a script for disabling the context menu in Opera, it’s bellow your comment.

    @jerone – Thanks :)

    @William – Well there are still some people that use Opera, maybe they don’t like switching browsers, or they just like Opera. Developers don’t use Opera (not the good ones anyway), they (we) use Firefox, for daily surfing and for developing websites. Also we use Chrome and Safari to test if what we have done works ok in those, and if it works then we test IE5, IE6, IE7, IE8 and none of them works as we want it :) And then 2 more days to make it compatible with those, and they are all different :)

  • IE5? for reals?
    wow thats hardcore ;-)

  • Believe it or not William, some clients want IE5 compatibility :) And IE isn’t making things easier for us, because with every version there are a lot of differences so it’s like having another browser that’s needed to be worked on. The only good thing is that they made a developing tool similar to FireBug, and to be honest they did a good job with it :)

  • I use Opera to navigate on the web and FF/Chrome/Safari/IE to test my websites (FF to debug).
    Opera is an awesome browser, it has tons of features that the other browsers don’t have. ;)

  • thank you very much …

Leave your own!

Sponsors

freedcamp free project management

Popular Articles

fzilla file hosting