• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to disable right click in a page

 
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They can always view the source or take a screenshot without right clicking anyway.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 249
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic