One of our clients had a situation where they wanted to stop people from replicating the files and find a quick way to safeguard copyright and IP policies in a given document library. Using a disclaimer web part they were able to shift the responsiblity on to the user. I recetly wrote another version for this script.

The javascript shows a dialog box to each new user on the site. The user sees the disclaimer text and is allowed to accept the policy, and go through or not accept it and the browser closes automatically. Incase the user accepts the poilicy the user won’t see the disclaimer popup for 365 days.

This little script here can be added into a CEWP in SharePoint:

<p align=”center”>DISCLAIMER GOES HERE</p>

<script type=”text/javascript” language=”javascript”>
var agreement = GetCookie();

//checks for cookie and displays disclaimer alert if new user
if(agreement==””)
{
var decision = confirm(“DISCLAIMER: GOES HERE \n\n Click Ok if you agree to the disclaimer or click Cancel to close this window. \n”);
if(decision == true)
{
//writes a cookie
var expiredays = 365;
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=”DCWP”+ “=” +escape(“Agree To Disclaimer”)+
((expiredays==null) ? “” : “; expires=”+exdate.toGMTString())
}
else
{
//redirect
//window.location = “/NotAllowed.aspx”;

// or even better close the browser window
window.opener=’x’;
window.close();
}
}

//gets the Cookie if it exists
function GetCookie()
{
if (document.cookie.length>0)
{
c_name = “DCWP”;
c_start=document.cookie.indexOf(c_name + “=”)
if (c_start!=-1)
{
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(“;”,c_start)
if (c_end==-1) c_end=document.cookie.length
return agreement = unescape(document.cookie.substring(c_start,c_end))
}
}
return “”;
}

</script>

Advertisements