Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Pop-Up Disclaimer in SharePoint

  Asked By: Anna    Date: Jan 29    Category: Sharepoint    Views: 9904

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!

Share: 

 

3 Answers Found

 
Answer #1    Answered By: David Lozzi     Answered On: Feb 21

Step 2 you say you hid it... what did you do to hide it?

Also, try removing some of the cookie checks, just get the prompt to work, then add the cookie checks.

And you can try your code on a normal HTML page and open it locally, to bypass SharePoint-isms.

 
Answer #2    Answered By: Daniel Partridge     Answered On: Feb 28

This appears to simply be an issue of where you have a hard return that is being viewed as an unterminated string constant in the "var decision" line.

This code worked and all I did is combine the "var decision" line with the followin line by removing the had return before "\n\n":

<html>
<head>
<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>
</head>
<body>
Done!
</body>
</html>

 
Answer #3    Answered By: Lina Ngon     Answered On: Mar 11

Hello,

I have followed the exact same step:
1. Created a content editor web part
2. Hid it
3. Pasted the code above
4. Cleared my cookies

The popup is still not showing up. Any suggestions?

 
Didn't find what you were looking for? Find more on Pop-Up Disclaimer in SharePoint Or get search suggestion and latest updates.




Tagged: