Blog > detail

Just my tiny mind

Disable Right Click and Selection

26-2-2012 Admin General 2 Comments

Disable Right Click and Selection

Disable Right Click and Selection is very useful for you to protect the content of your website. By using this, the visitor cannot select an area of your page and right click on it. Disable Right Click and Selection is realy a simple code, but indeed it is very powerfull.


Lets just jump to the code for disable right click:


var msg="Right Click has been disabled!";//Give alert here

document.oncontextmenu=new Function("alert(msg);return false");//give alert

//document.oncontextmenu=new Function("return false");//open this row to give no alert


Lets just jump to the code for disable selection:


function stop(){return false;}

function allow(){return true;}

document.onselectstart=new Function ("return false")

if (window.sidebar){

document.onmousedown=stop;

document.onclick=allow;

}


Unfortunantely, several blog or public site have disabled the javascript like this wordpress that I use. Therefore I cant implement my own code in this page. However, I have tried Disable Right Click and Selection on local server and it work successfully. I also try Disable Right Click and Selection with IE8, Google Chrome 10.0.648.205, Safari 5.0.4,and FireFox 4.0b10.


Just copy this  into your HTML page. Hope Disable Right Click and Selection simple code can help you alot.


Disable Right Click and Selection Disable Right Click and Selection Disable Right Click and Selection

Disable Right Click and Selection Disable Right Click and Selection Disable Right Click and Selection

Disable Right Click and Selection

word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word

Disable Right Click and Selection

Disable Right Click and Selection

Disable Right Click and Selection