Disable Right Click on My Website

A Place To Talk About HTML,SHTML,XHTML, HTM,XML,CSS, JS,PHP,,Etc
Post Reply
User avatar Romania
Dragosvr92
Administrator
Administrator
Posts: 1107
Joined: 11 Sep 2009, 06:04
Name: Dragoș-Valentin Rădulescu
Location: Romania
Age: 30
Contact:

Disable Right Click on My Website

Post by Dragosvr92 »

This script code will allow you to disable the right mouse click by
adding it between your body tags <body></body>

___________________________________________________________________________
Formerly known as TheKiller
ImageImage
User avatar Romania
Dragosvr92
Administrator
Administrator
Posts: 1107
Joined: 11 Sep 2009, 06:04
Name: Dragoș-Valentin Rădulescu
Location: Romania
Age: 30
Contact:

Re: Disable Right Click HTML Code

Post by Dragosvr92 »

To Disable The Right click by HTML Use the fallowing code

Code: Select all

<BODY oncontextmenu="return false"</body>
Keywords: Disable The Right Click
Formerly known as TheKiller
ImageImage
User avatar Romania
Dragosvr92
Administrator
Administrator
Posts: 1107
Joined: 11 Sep 2009, 06:04
Name: Dragoș-Valentin Rădulescu
Location: Romania
Age: 30
Contact:

Re: Disable Right Click Javascript

Post by Dragosvr92 »

Script To Disable The Right-Click On An HTML Page


This script code will allow you to disable the right mouse click by adding it between your body tags ~ <body></body>.And will also display a pop-up message.

Note : if you want to use the JS Code into an .js File just remove the tags

Code: Select all

<script language=JavaScript>
</script>
___________________________________________________________________________

[code]<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Sorry But the Right Click is 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>
or you can use this shorter version

Code: Select all

<script language=Javascript1.2> function ejs_nodroit() 
{
 alert('Sorry But the Right Click is Disabled');

 return(false);

 }
 document.oncontextmenu = ejs_nodroit;
</script>
Formerly known as TheKiller
ImageImage
Post Reply