Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable middle click button

    Hi guys,

    At the moment i have this code which disable the middle button in Safari and Chrome..

    Code:
    $('body').mousedown(function(e){
    		if(e.button==1)
    		return false
    	}
    );
    How can I disable it in Firefox and IE?.. i think IE middle button ==4 but its not working for me.

    Thanks in advance!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,029
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    http://unixpapa.com/js/mouse.html

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    How critical is it that you be able to disable the middle mouse button?

    If not at all, then I wouldn't bother.

    1) If javascript is turned off or not available in the user's browser then your javascript will not work anyway.

    2) Users can configure the mouse button to do things other than what you expect and if you disable those functions then you run a high risk of losing that visitor.

    Why do you want to disable the middle button? There might be better alternatives.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,641
    Thanks
    0
    Thanked 649 Times in 639 Posts
    The middle mouse button is the one people are most likely to configure to perform the action they want to make most convenient to use since it is the one they would otherwise be least likely to use.

    It will do different things in different browsers even if they don't change it. What you are trying to do is the equivalent of telling people around the world not to catch a number 10 bus because your local 10 bus goes somewhere you don't want them to go.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Tags for this Thread

    Posting Permissions

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