Friday, 13 June 2014

How to disable right click in blog or website

                                      

Blogger o webmaster are always in search of widgets to make their blog or website look awesome but although good look is important for website but security is also important , If you don't want visitors to be able to access the context menu that is right click in your blog or website because there are some features in right click which you might want to be disabled for visitors lik
e copy, inspect element, etc. Disabling right click is will not allow access to this option but still there are some keyboard shortcuts that can be used by visitors, so they can select text in your blog/website and press CTRL + C to copy it. To prevent this we will learn the first way in this post that is how to disable right click on blog/website ,the second step is to disable text selection, that you will learn in another post at here.

Method 1 : Using javascript


  1. Go to blogger.com , login in it and open the blog in which you want to disable right click. Or if you have your web site then open the HTML files of your website's pages in which you want to disable the right click.
  2. Then in blogger click on layout on the left side.

  3. In it click on add a gadget option.

  4. A list of gadgets will appear in a new window, in that find html/javascript gadget and click + button in front of it.

  5. Now a page will load in it, in that there will be a content area in that copy and paste the following code. If you have website instead of blog then simply copy and paste the following code before </body> tag in your website.
  6. click to get code
  7. Click save option in that window.Save changes to your website.
  8. Then click save option in layout( for blog).And then the right click will be disable in your blog or website.
Method 2 : Using HTML attribute
If the Method1: Using javascript is not working for you or if you have any problem using that method then you can use this method to disable right click on your blog or website.
  1. If you are using blogger login in it, and open blog in it in which you want to disable right click.
  2. Click template option on left. And then on the right side click edit HTML. If you are having website instead of blog then open the HTML file of your website in which you want to disable right click.

  3. In that template editor (that your opened after click edit HTML)Press CTRL + F (this will open find box ) in that box type <body and press enter that will take you to the <body tag.
  4. If you are having website instead of blog do the same thing that is press CTRL + F (to open fin box)
    in the find box type <body and press enter key. 
  5. After that you will be taken to a body tag that will look like <body>, in some case it might have something inside that like <body onload="function">, etc but that does not matters.
  6. Now in that body tag add add the following oncontextmenu='return false'
    So it will look like <body oncontextmenu='return false'> This is correct way.
    <bodyoncontextmenu='return false'>This is wrong way

  7. Click save template in the template editor or save changes to HTML of your website and right click in your blog or website will be disabled.