-1

Possible Duplicate:
How do I disable right click on my web page .

is it possible to disable the right click on webpage's control like textbox, link etc. using Javascript.

Community
  • 1
  • 1
Student
  • 3,469
  • 7
  • 35
  • 42
  • 8
    Don't do this, unless you have a really good reason. This is generally a terrible web practice to follow. Why would you want to disable the menu? – Brad Mar 21 '11 at 13:37
  • Why it is generally a terrible web practice to follow ? – Student Mar 21 '11 at 13:46
  • 5
    Your users are in control, not you. What if they want to right click to go back, forward, print, view page source, save an image, translate, etc. This isn't up to you, it is up to the user. You are taking away from the usability of your page, annoying your users, and for what? I have yet to hear an argument as to what benefit you gain from this. The only thing I can think of is if you are overriding with your own context menu. – Brad Mar 21 '11 at 13:49
  • 1
    @Student disabling right clicking is just annoying, and doesn't stop people from copying who want to copy... maybe it would stop my grandma idk. – Loktar Mar 21 '11 at 13:50
  • @Brad I know that my users are in control not me. I just make their way harder. We all know that not any AntiVirus software in this world can stop very single virus, but we still use them to stop virus. – Student Mar 21 '11 at 14:03
  • 1
    @CoolCool, why would you want to make **anything** harder on your users? What are you trying to stop them from doing? – Brad Mar 21 '11 at 14:05
  • every thing what you have mentioned in your previous comment. – Student Mar 21 '11 at 14:06
  • 1
    @CoolCool, ... I give up. Go ahead, keep cranking out sites with things like this. Webmasters with these attitudes keep me employed. – Brad Mar 21 '11 at 14:11
  • 1
    @CoolCool WTF? Oh, I see - you should have mentioned in your question that you are programming a website for visitors who wish to get annoyed a bit... – Martin Hennings Mar 21 '11 at 14:12
  • @Brad and @Martin now you are abusing me, I respect your opinion but it seems that you not respect other. Both of you have used abusive word for me. But I am still nice to you. – Student Mar 21 '11 at 14:51
  • @Student: I think you were planning to post that last comment *@Brad and @Martin now you are abusing me, I respect your opinion but it seems that you not respect other. Both of you have used abusive word for me. But I am still nice to you. – Student 12 mins ago* from your CoolCool sock puppet account, otherwise you make the [vote fraud](http://blog.stackoverflow.com/2008/12/vote-fraud-and-you/) a bit too obvious... – Hans Olsson Mar 21 '11 at 15:03
  • @ho1 its me because they are abusing me indirctly – Student Mar 21 '11 at 15:08
  • @Student, I have not made any comment towards you... and I haven't downvoted anything here. Your answer is perfectly correct for the question, just not something I would recommend, but that has nothing to do with your answer. I am thoroughly confused. – Brad Mar 21 '11 at 15:14
  • @CoolCool: Not to worry, I've flagged the moderators, so we can let them decide who's using fake accounts. – Hans Olsson Mar 21 '11 at 15:18
  • @Brad because you have used comment "cranking out sites with things like this. Webmasters with these attitudes" this give me impression. You should not use these kind of words. – Student Mar 21 '11 at 15:23
  • @Student, that was directed towards CoolCool, not you, and I don't believe they were particularly aggressive. I apologize if anyone feels that they were. I am simply trying to get my point across in a way that might resonate better. – Brad Mar 21 '11 at 15:26
  • @Brad: Important thing to remember is that Student and CoolCool is the same person, then the fact that STudent replied to a comment aimed for CoolCool makes perfect sense. Just look at their question/answer history. – Hans Olsson Mar 21 '11 at 15:33
  • @ho1, Holy cow, you're right! I didn't believe you at first, but after looking at all of the questions/answers, that is quite clear. I can't believe I've wasted time on this. Student's account is now suspended. He's just left with CoolCool now. – Brad Mar 21 '11 at 15:36

1 Answers1

8

Just add

<body oncontextmenu="return false;">


Now you can prevent right click on control of webpage
Through this you can only stop novice users not experienced or expert users.

Student
  • 3,469
  • 7
  • 35
  • 42
  • 2
    This doesn't stop any willing visitor to copy something from your website. Simplest thing would be to disable JavaScript. Next idea would be to use firebug or such to remove the annoying tag... – Martin Hennings Mar 21 '11 at 13:42
  • 1
    @Martin, why would you want to stop anyone from copying something from your website? As if you could anyway... Don't bother with this. **Edit:** I think that is actually what you were getting at. +1 for you. – Brad Mar 21 '11 at 13:46
  • 1
    +1 for not rhetorically asking "why would you want to do this" – puk Oct 17 '12 at 05:36