Microsoft.NET

……………………………………………….Expertise in .NET Technologies

Disable right mouse click, Disable Browser Back Button

Posted by Ravi Varma Thumati on October 20, 2009

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>
<!–

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>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: