how to block right-click on my site

mukth's picture

They have: 3 posts

Joined: May 2009

Hi, anyone can help ?

i want to Block right-Click when some one visit My Website and also don't allow to save the Web Page ,
is it possible to do it with Simple HTML code ?
any help appreciated ,

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

Simply replace <body> with <body oncontextmenu="return false;">

It is not possible to prevent someone from saving the webpage, as once they visit the page it has already been downloaded into their Temp folder for your browser to display to you.

Hope this helps Smiling

All the best news here: https://newsbotnet.com

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Here is another thread on this topic:

http://www.webmaster-forums.net/html-css-and-javascript/how-block-right-...

Just keep in mind that you're probably going to annoy a lot of people who use right-click to access other browser functions.

I've never heard of any way to block users from file > save as. Why are you so worried about people saving the page?

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

IMO, the people you "Stop" with disabling the right click are not going to have skills to do anything with your site you need to worry about.

Also, for people like me who like to right click to click on BACK for the browser, it will annoy (I really hate not having a back button on the mouse for my laptop!)

-Greg

DarkLight's picture

He has: 287 posts

Joined: Oct 2007

That's right. If the guy has the skills to actually "use" your coding, then he will also have the skills to "null" the no-right-click function. E.g. javascript:void oncontextmenu(null)

In addition, I never use right-click for getting the source code, I simply hit CTRL+U, which opens the code up directly. I don't know if that works for anything other than Firefox, though.

All the best news here: https://newsbotnet.com

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

There is also the option to do File -> Save Page as in most browsers's menu bar.

greg's picture

He has: 1,581 posts

Joined: Nov 2005

  • File --> Save as
  • View --> View Page Source
  • Firebug
  • Viewing your PC internet files as all your website content is saved in my local hard drive
  • etc

Are all methods that even kids know how to do. It really is a bad idea as you remove functionality to genuine users, 99.999% of visitors.

And as Greg pointed out, it only stops the people who are of no danger.
Anyone of any threat will have learned ways around the right click when they were 5 years old.

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

When they were 5 years old???

That was 1977! 8 years before I got my first computer.

LOL, couldn't resist.

-Greg

greg's picture

He has: 1,581 posts

Joined: Nov 2005

Greg K wrote:
That was 1977!

No grasshopper, hackers are only 12 yo these days, making it 2002 Laugh

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.