This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to disable right click in a page

 
PavanPL KalyanK
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont want allow the user to copy the content on the screen
so please tell me
How to disable right click in a page

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Modern day browsers will not let you do this and if they have JavaScript disabled than your protection does not work.

A google search will give you the answer. Bet solution is if you do not want people to take it, do not put it online.

Eric
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They can always view the source or take a screenshot without right clicking anyway.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rude and useless. Don't bother trying to work around it, you can't.

Also, please read this for more information.
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pavan

Here it is, Simply Add the below script in the body section of your page this will disable the script. Anyway others can track the source using page source or screen shot.

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I love seeing document.layers in code, makes me realize people are tyruing to support a 10 year old browser.

Eric
 
Dawn Charangat
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I accidentally uncovered a very easy way to do this during my first project in IT industry - as a fresher... and I just love it.
Type in this code in the <body> tag

<body oncontextmenu="return false;">


and enjoy the look on the user's face when he right clicks on the page
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As said before, one can still grab the content by just disabling JS, or exploring the browser cache, or taking a screenshot.

Useless and rude. You should never try to change the client's environment/behaviour. Disabling the back button falls in the same story.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dawn Charangat wrote:I accidentally uncovered a very easy way to do this during my first project in IT industry - as a fresher... and I just love it.
Type in this code in the <body> tag

<body oncontextmenu="return false;">


and enjoy the look on the user's face when he right clicks on the page


Try it in modern day browsers with default settings....

Eric
 
Dawn Charangat
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You were right Eric.... It did not work in IE 7

But hey, it works just fine in Chrome 1.0.154.53 and Mozilla Firefox 3.0.7

[those are the only web browsers I have in my lappy.... so can I claim partial success ]

Dawn
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dawn Charangat wrote: so can I claim partial success

Partial success is just another phrase for failure.

Hacks, especially those that only work on some browsers, are never a proper solution.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic