Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add an alert banner to a SharePoint site

Posted on 2011-09-12
10
Medium Priority
?
1,343 Views
Last Modified: 2012-05-12
I have a task to add an alert banner to a SharePoint 2007 site that would prompt a user to accept a disclaimer before they are allowed into a site. What would be the best way to accomplish this?
0
Comment
Question by:Tec-Futures
  • 5
  • 4
10 Comments
 
LVL 3

Expert Comment

by:dyuburg
ID: 36522625
0
 
LVL 9

Expert Comment

by:Tehzar
ID: 36522763
Hi Lanzowallace,

This solution is based on Content Editor Web part, it wors for both versions of SharePoint:

http://phase2.com/blog/?p=1242
0
 
LVL 1

Author Comment

by:Tec-Futures
ID: 36524184
The phase2 examples does not work. The logic is what I am looking for but the code is buggy and does not work. Were you able to make it work?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 9

Expert Comment

by:Tehzar
ID: 36524205
It did work for me, let me find it and i'll post it for you.
0
 
LVL 1

Author Comment

by:Tec-Futures
ID: 36529553
Tehzar ,
Were you able to find your working code?
0
 
LVL 9

Accepted Solution

by:
Tehzar earned 2000 total points
ID: 36529944
Be sure to delete your browser cache and close the browser/reopen it.  

Also, sometimes when you copy paste code in, it reformats the apostrophes into quotes (so be sure to check that)
<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 or Message GOES HERE');

if(decision == true){

//writes a cookie

var expiredays = 365;

var exdate=new Date()

exdate.setDate(exdate.getDate()+expiredays)

document.cookie='cookiename'+ '=' +escape('Agree To Disclaimer')+

((expiredays==null) ? '' : '; expires='+exdate.toGMTString())

}

else{

location.href='/_layouts/SignOut.aspx';

}

}

//gets the Cookie if it exists

function GetCookie(){

if (document.cookie.length>0){

c_name = 'cookiename';

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>

Open in new window

0
 
LVL 1

Author Comment

by:Tec-Futures
ID: 36545200
Tehzar,
The code you provided works perfectly. The only piece left is how to make the cookie expire after the browser close. The current expiration is set for 365. After reading a few blogs I found a few entries that said leave the expire date blank and it will expire when the browser is closed.

When I tried to mod the code to leave expire date blank it does not create a cookie for the current session. I would like the cookie to exist only for the current session and any pages accessed during that session.  Currently the popup keep repeating every time I leave the homepage and come back within the active session. The cookie should be good for the active session only and re-prompt the user to accept the disclaimer when he or she returns to the page.

Thank you for your response.
0
 
LVL 9

Expert Comment

by:Tehzar
ID: 36545690
try setting the expiration to -1

Please let me know if this works out, if not, I'll rework it tonight.  HTH!

Cheers,

ZaR
0
 
LVL 1

Author Comment

by:Tec-Futures
ID: 36548218
Tehzar:,
No -1 did not work. the cookie is not generated.
0
 
LVL 1

Author Comment

by:Tec-Futures
ID: 36548524
Tehzar,
I just tried removing = 365 and left var expiredays ; and it seems to be working fine. I will post it today and let you know if the code works.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question