Sometimes in your web application you will have a link to a file on the server. Problems occur when the user clicks on the link and opens the file in the browser. If the user wants to save the file he will get an error. To force the user to dowload the file you can disable the left click but keep right clicking enabled.
To make the script accessible on all web pages I declared the script in the default.aspx file
<head id="Head" runat="server">
<script language="javascript">
function noLeftClick()
{
if (event.button==1)
{
alert('Please use the rightclick \"Save Target As\" Command to Download')
}
}
</script>
</head>
In the html content you have to add the call to the javascript :
<a href=http://server.filename.xls onMouseOver='document.onmousedown=noLeftClick' onMouseOut='document.onmousedown=null'>filename</a>
As you see, you can right click and save the target as, but you can not directly click on it.