Disable right click on SQL reporting services report in SharePoint 2007
September 20th, 2007 — ¥ong¥s
We are working on SharePoint Workspace with Business Intelligence solution. There some report build with reporting services show in SharePoint page. Then, we come across a special requirement that the client do not allow user to “Right click” on the entire SharePoint page including the reports. If you are using page viewer or report web part to view the report in native mode, you will never able to include your JavaScript to disable the right click. This is because it using iFrame to link to the report. To overcome this problem, there are 3 steps need to be done.
- Install and configure Reporting Services Add-in for SharePoint
First, we need to install the “Microsoft SQL Server 2005 Reporting Services Add-in for Microsoft SharePoint Technologies” add-in and change reporting services to SharePoint integration mode. You can download the add-in in https://www.microsoft.com/downloads/details.aspx?familyid=1E53F882-0C16-4847-B331-132274AE8C84&displaylang=en and get some introduction on its benefit here http://blogs.msdn.com/SharePoint/archive/2007/02/19/microsoft-sql-server-2005-sp2-reporting-services-integration-with-wss-3-0-and-moss-2007.aspx . You need to configure the reporting services after installed the add-in. You can easily find some help via google. Once done, you have to upload some report to SharePoint document library. - Add JavaScript to disable the right click on SharePoint.
To simplify the story, we use Content Editor Web Part to ad in the JavaScript. Enter code below in “Source Editor”:
<SCRIPT language=”JavaScript” >
function queryString(parameter) {
var loc = location.search.substring(1, location.search.length);
var param_value = false;
var params = loc.split(”&”);
for (i=0; i<params.length;i++) {
param_name = params[i].substring(0,params[i].indexOf(’='));
if (param_name == parameter) {
param_value = params[i].substring(params[i].indexOf(’=')+1)
}
}
if (param_value) {
return param_value;
}
else {
return false; //Here determine return if no parameter is found
}
}
function right(e) {
if (navigator.appName == ‘Netscape’ &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == ‘Microsoft Internet Explorer’ &&
(event.button == 2 || event.button == 3)) {
alert(”Sorry, you do not have permission to right click.”);
return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
</script>

The right click will disable on the specify page now.
Read the rest of this entry »


