Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1386
  • Last Modified:

Add an alert banner to a SharePoint site

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
Tec-Futures
Asked:
Tec-Futures
  • 5
  • 4
1 Solution
 
TehzarCommented:
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
 
Tec-FuturesAuthor Commented:
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
TehzarCommented:
It did work for me, let me find it and i'll post it for you.
0
 
Tec-FuturesAuthor Commented:
Tehzar ,
Were you able to find your working code?
0
 
TehzarCommented:
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
 
Tec-FuturesAuthor Commented:
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
 
TehzarCommented:
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
 
Tec-FuturesAuthor Commented:
Tehzar:,
No -1 did not work. the cookie is not generated.
0
 
Tec-FuturesAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now