Hi all,
I was asked to make a Pop-Up Disclaimer in SharePoint that appears the first time a user enters the SharePoint (or actually the first time after the Pop-Up Disclaimer has been created). But for some reason I cannot get it to work. Here is what I have done:
1. Created a Content Editor Web Part
2. Hid it
3. In Source Editor wrote the following code (I copied the code from a website, but I can't access it anymore as it was on a blog and I am currently in China):
<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 text.
\n\nClick Ok if you agree to the disclaimer or click Cancel to close this window. \n");
if(decision == true)
{
// writes a cookie
var expiredays = 7;
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie="PartnerAgreement"+ "=" +escape("Agree To Disclaimer")+
((expiredays==null) ? "" : "; expires="+exdate.toGMTString())
}
else
{
// redirect
window.location = "/_layouts/signout.aspx";
// or close the browser window
//window.opener='x';
//window.close();
}
}
// gets the Cookie if it exists
function GetCookie()
{
if (document.cookie.length>0)
{
c_name = "PartnerAgreement";
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>
4. Deleted all my cookies and reopened my IE.
However, at this point, when I reopen the SharePoint, nothing happens - i.e., I do not see the disclaimer.
Thank you in advance for your help!