Friday, June 15, 2012

Disable Right-Click Function To Your Website

Today I will be teaching you how to protect the content of your website or blog - the images, texts, information and even the source code. These are some useful scripts that can be used to disable Right-Clicking / Right-Click function in your website.

Protecting your content is one way to be unique over the internet. It is also very beneficial if you are monetizing your blog especially when you are using Full-Page Script .

The techniques that I'm going to show does not guarantee 100% protection but at least, it will lessen or minimize the leechers. There are specialized scripts and codes that can be used but it's much more advance. The thing is, those who really want to steal any of your valuable content or information will always find a way to bypass it. 

First, just copy the script code then paste them to any of the following:
  • Easy Way:  You can place the code to any HTML/Javascript gadget (ex. Add Gadget "HTML/Javascript" in Blogger) or anywhere content of the page (by configuring them in HTML format). Same rules applied to any other web host or blog host. Just place the code to any web page you wish to protect.
  • Advanced: You can place the code anywhere in between the <head>....</head> but as much as possible, place it before the </head> or after the <head> tag so you can easily recognize and find it.

Now that you know how to place them, I will give you several different ways to disable it:

  1. [ DRCF_CODES_1 ] Disable Right-Click Function with Dialog Box Script
  2. DRCF_CODES_2 ] Disable Right-Click Function without Dialog Box Script
  3. DRCF_CODES_3 ] Disable Text Select Script

Please use CTRL+F then copy-paste or type the code *ex. DRCF_Codes1* of your chosen script you wish to use. The scripts are quite long, use this method so you can easily reach 1 script then another.


All scripts are tested by me and yes, they are working. I have been using them to my other blogs. If you have problems using them, feel free to ask question or post a comment below. Read my notes before using them.


V ------------------- v[ DRCF_CODES_1 ]v -------------------  V


Applying the code below will disable the right-click function and will show a Dialog Box when the visitor press the Right-Click of the mouse.



<script language=JavaScript> 
<!--
//Disable right mouse click Script
//Tutorial by The Snow Cone
//http://thesnowcone.blogspot.com
var message="Function Disabled!";
///////////////////////////////////
function clickIE4(){
if (event.button==2){alert(message);
return false;}}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;}}}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;}
document.oncontextmenu=new Function("alert(message);return false")
// --> 
</script>
NOTE: You can modify the message you wish to be shown in the dialog box. This is by finding the var message (the red-colored) then changing the blue-text colored phrase as seen below:
var message="Function Disabled!"

V ------------------- v[ DRCF_CODES_2 ]v ------------------- V

Disable the right-click function but this time, no dialog box will appear.
<SCRIPT TYPE="text/javascript">
<!--
//Disable Right-Click Tutorial - No Dialog Box
//by SnowCone http://thesnowcone.blogspot.com
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT>
Note: You may no longer change the "var message" since it will not show any dialog box.

V ------------------- v[ DRCF_CODES_3 ]v ------------------- V


Disable the text-select by using the code below. This will disable the visitor to select text. I personally recommend this script because it will prevent them to copy (CTRL+C) the content of your website.

<SCRIPT TYPE="text/javascript">
<!--
//Disable Text Select
//By SnowCone http://thesnowcone.blogspot.com
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
// -->
</SCRIPT> 
Note: You may no longer change the "var message" since it will not show any dialog box.
V ------------------- v[ TUTORIAL END ]v ------------------- V

This are just the three simple ways in protecting the content of your website. If you also want to use my tutorial and post it to your blog, no need to ask permission, just put me some proper acknowledgement and credits. I recommend you also not to change anything from it unless it is indicated or noted (ex. var message) otherwise the script will not function properly.

I will repeat, it does not guarantee 100% protection of your content but will lessen/minimize content stealing and leeching.

I highly recommend using the disable text select [ DRCF_CODES_3 ] plus either of the first two codes ( with dialog box [ DRCF_CODES_1 ] or without dialog box [ DRCF_CODES_2 ] ). It's, by far, the best combination for me.

I hope it helped you a lot! :)

0 comments:

Post a Comment

Please use the Name/URL option instead of Anonymous so I can address you properly using your name or code names.
You can also indicate your website so we can check each other out otherwise leave it blank if you don't have any. Feel free to send me an
e-mail
if you have any questions, comments, suggestions, requests, or legal claims.