Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 7025

Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 2162

Deprecated: Hook imagify_allow_picture_tags_for_webp is deprecated since version 2.2! Use imagify_allow_picture_tags_for_nextgen instead. in /www/collab365_296/public/wp-includes/functions.php on line 5758
Disclaimer Popup in SharePoint 2010 or 2013 - Collab365
Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Deprecated: strstr(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1145

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1152

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1155

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1162

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /www/collab365_296/public/wp-includes/functions.php on line 1165

Warning: Undefined array key "url" in /www/collab365_296/public/wp-content/plugins/thrive-visual-editor/thrive-dashboard/inc/smart-site/classes/class-tvd-smart-shortcodes.php on line 85

2015-05-15

Having a disclaimer popup in SharePoint is something that is necessary for many businesses and their internal external web sites.  This is usually a mandate for legal requirements for tracking legal agreements.  Recently we had to add a disclaimer that upon agreement granted you access to the existing extranet site.  After reading the disclaimer users would either press ok or cancel.

  • [Ok] allows you in the site, drops a cookie on your machine and grants you access to the entire site and sub-sites until the next year when the cookie expires.
  • [Cancel] will take you out of the site and request your login again.
  • The cookie will be active on all sites and sub-sites in SharePoint, any URL from the root.

In order to perform this you need to have the disclaimer JavaScript in every site and sub-site in the root zone.  This is accomplished by the path=/.  All you have to do is place this code in the default masterpage at the bottom in between the </body> and the </html> tags.  Change the disclaimer under the decision variable.  The popup will only occur once.  Special thanks to my friend Ed Goad and his book he wrote, Windows Server 2012 Automation with PowerShell Cookbook this inspired me to right this JAVA script.  Here is the code that I wrote that performs this activity.  Be sure to save check in and publish the masterpage if you are editing in SharePoint designer.

<script type="text/javascript" language="javascript">

var agreement = GetCookie();

// checks for cookie and displays disclaimer alert if new user

if (agreement == "") {

//Author: Tony Di Leonardo

var decision = confirm("DISCLAIMER: GOES HERE \n\nClick Ok if you agree to the disclaimer or click Cancel to close this window. \n");

if (decision == true) {

// writes a cookie

var oneMinute = 60 * 1000

var oneHour = oneMinute * 60

var oneDay = oneHour * 24

var today = new Date()

var nextXmas = new Date()

nextXmas.setMonth(11)

nextXmas.setDate(31)

if (today.getMonth() == 11 && today.getDate() > 31) {

nextXmas.setFullYear(nextXmas.getFullYear() + 1)

}

var expiredays = nextXmas.getTime() - today.getTime()

expiredays = Math.floor(expiredays/oneDay)

var exdate = new Date()

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

document.cookie = "PartnerAgreement" + "=" + escape("Agree To Disclaimer") +

((expiredays == null) ? "" : ";path=/; 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>

 

(Visited 557 times, 1 visits today)

About the author 

Tony Di Leonardo

Summit Bundle

Get 200+ hours of Microsoft 365 Training for 27$!

Master Office 365, Power Platform & SharePoint & Teams With 200+ Hours Of Training Videos and 108 Ebooks in the Collab365 Academy. This offer is insane and is only available for a limited period.