If you have images (or anything else) on your website that want to protect then you can disable "right-click", which is how people get to the "Save As" option. This is not a perfect solution because anyone with advanced web experience can get around this, but it will stop most people from stealing anything you have a copyright on. You can use any (no need to use more than one) of the codes below to block "right-click" functionality, which will prevent most attempts to save your stuff.
Once you have selected the code from below that you want to use, follow these step…
1. Paste the code you select from below into the box titled JavaScript for <head>
Disable Right-Click
<script type="text/javascript">
var message="Right-Click 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>
Disable Right-Click Without an Alert Message
<script type="text/javascript">
var message="";
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>
How to Disable Right-Click on Images Only
<script type="text/javascript">
var clickmessage="Right click disabled on images!"
function disableclick(e) {
if (document.all) {
if (event.button==2||event.button==3) {
if (event.srcElement.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}else if (document.layers) {
if (e.which == 3) {
alert(clickmessage);return false;
}
}else if (document.getElementById){
if (e.which==3&&e.target.tagName=="IMG"){
alert(clickmessage);
return false;
}
}
}
function associateimages(){
for(i=0;i<document.images.length;i++){
document.images[i].onmousedown=disableclick;
}
}
if (document.all){
document.onmousedown=disableclick;
}else if (document.getElementById){
document.onmouseup=disableclick;
}else if (document.layers){
associateimages();
}
</script></document.images.length;i++){
No comments:
Post a Comment