在SharePoint 2013中
我有一个显示免责声明的脚本。此脚本创建一个cookie,我想删除cookie或将其设置为在用户注销时过期。
这可能吗?
<p align="center">DISCLAIMER GOES HERE</p>
<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: 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 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 "";
}
答案 0 :(得分:1)
你当然可以试试。当您按&#34;退出&#34;您将被重定向到C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS
文件夹中的SignOut.aspx页面。尝试在window.close()
语句之前向其脚本块添加代码。更改aspx页面后不要忘记执行iisreset。