Saturday 19 April 2008

Disable right mouse click, Disable Browser Back Button

Sometime our application demands to change some of the normal workflow of the Browsers. Here are the few tweaks in programming which may help you to do that.

Do not allow user to view page using browser back button.

<%Response.Cache.SetCacheability(HttpCacheability.NoCache); %>

Disable Right Click

This is a cross browser DHTML script that will prevent the default right menu from popping up when the right mouse is clicked on the web page. Use it to stop surfers from easily saving your web page, viewing its source, or lifting images off your site when using either IE 4+ or NS 4+.

<script language=JavaScript>
<!--

var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layersdocument.getElementById&&!document.all){
if (e.which==2e.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>

Share:

0 comments:

Post a Comment