www.webdeveloper.com
Results 1 to 7 of 7

Thread: block rightmouse button

  1. #1
    Join Date
    Nov 2005
    Location
    Poland
    Posts
    3

    block rightmouse button

    Hello,

    How to block the roght mouse button,
    so no action will be taken (pop-up menu will not be shown)

    Thanks!

  2. #2
    Join Date
    Jun 2005
    Location
    Georgia
    Posts
    155
    Code:
    <body oncontextmenu="return false;">
    That takes care of the menu coming up for right-click and the menu button on the keyboard.

    lonogod

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Only works for IE and is guaranteed to annoy users.
    At least 98% of internet users' DNA is identical to that of chimpanzees

  4. #4
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    See http://javascript.about.com/library/blright.htm for the easiest way to reenable the context menu for when someone puts code on their page that attempts to block your access to your menu in your browser and where you are using a browser that is stupid enough to allow them to do so.
    Stephen

  5. #5
    Join Date
    Jun 2005
    Location
    Georgia
    Posts
    155
    Works in FF and IE. I don't know about other browsers but I know it works in FF and IE.

    lonogod

    PS: I agree that it is very annoying and useless.

  6. #6
    Join Date
    May 2005
    Posts
    33

    Arrow yea...

    HTML Code:
    <script language=JavaScript>
    <!--
    
    var message="";
    ///////////////////////////////////
    function clickIE() {if (document.all) {(message);return false;}}
    function clickNS(e) {if 
    (document.layers||(document.getElementById&&!document.all)) {
    if (e.which==2||e.which==3) {(message);return false;}}}
    if (document.layers) 
    {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
    else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
    
    document.oncontextmenu=new Function("return false")
    // --> 
    </script>


    yea..... why do u wanna do that anyhow???

    quite annoying.... just doesnt make sense.... anything that someone can do with a right-click, they can do by going up to the menu of their browser and doing it manually.....


    ***********************EDIT



    works in IE, FF, Safari i THINK....
    Last edited by s0nofr4g3; 11-27-2005 at 07:46 PM. Reason: forgot something.... about browsers....

  7. #7
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Opera ignores any attempt by the web page to block browser functions such as this. With other browsers it can be easily bypassed using a bookmarklet eg. http://javascript.about.com/library/blright.htm
    Stephen

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles