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 15 of 15
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable right click over specifik elements?

    Is it possible to dissable right click over specified elements but not over the entire document?.


    PS. I wanna disable the right click cause I am using it to something else.

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    it is possible, but generally a bad idea due to users wanting to keep the same functionality of their browser. They can always circumvent what you are doing by turning off javascript anyway.

    There's a phrase that goes something like, "JavaScript should always be used to enhance, not inhibit a user's experience". I can't remember the exact wording but essentially in removing the right-click, you'd be inhibiting the user from using their natural menu systems.

    hope this helps

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Decent web browsers ignore any attempt to disable the right mouse button. For the others theres always tohe enable right click bookmarklet to bring it back. http://javascript.about.com/library/blright.htm
    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.

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well now 2 have told me what I already knew that such a script could be disabled, but still no one has actually posted a script or a link to a script that actually achieved what I wanted.

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Its pointless. There is no real gain in doing what you want other than hindering the browsing experience of the user. http://www.dynamicdrive.com/dynamicindex9/noright2.htm

    All it takes is some simple searching.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    There is no script that will disable the right mouse button in a decent web browser.
    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.

  • #7
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    i'd be curious to know exactly what you wish to do with the script. while the approach is looked down upon your application might warrent it... just explain it
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the reason:
    http://donp.the-hive.dk/?f=minesweeper

    currently I am using one of those scripts that disable right clicking in the entire document, but I really only need to disable it over the lesser area that is the game board.

  • #9
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    ahh you see, that makes a lot of sense.

    now let me ask you, do you need the right click to perform an alternate function, or you just don't want it at all?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #10
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes you place flags with rigth click as you always have

  • #11
    Senior Coder
    Join Date
    Jul 2003
    Location
    My pimped-out igloo in Canadia
    Posts
    1,966
    Thanks
    36
    Thanked 0 Times in 0 Posts
    k

    did you find what you needed or are you still looking?
    Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)

  • #12
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    I would recommend allowing right click and shift+click to set mines, just in case they have their browser set to force contextmenu ability.

  • #13
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I used JKD idea and now allow people to choose between either rigth click or shift+left click.

    Thanks for the help to those that put an effort into it.

  • #14
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How does one enable right click when it has been disabled by a website?

  • #15
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,149
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    This is a very old thread and you should really start a new thread regarding your question.

    Simply copy following script and put it into address bar of the browser. Right click will be enabled again.

    javascript:void(document.oncontextmenu=null);

    which demonstrates the futility of no-right-click scripts.


    Quizmaster: In nature, what invertebrate has a name which literally means "one hundred feet"?
    Contestant: Giraffe


  •  

    Posting Permissions

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