修改MOSS的注销方式,变简单一点.
在网上看的文章,但那个代码似乎有点老了,很多冗余的判断,而且还只支持IE,我稍微修改了一下,把它删掉了一点:
<!--
function Logoff()
{
if (navigator.appVersion.indexOf("MSIE") > 0)
{
try
{
document.execCommand("ClearAuthenticationCache","false");
self.location.href = ".";
}
catch (e)
{
alert("需要IE6.0以上版本.");
}
}else{
window.location.href="/_layouts/signout.aspx";
}
}
//-->
</script>
-------------------------------------------------------------------
原文:
曾经有客户觉得SharePoint站点的注销不够友好,想能直接点击就可注销,看了一下SharePoint自带的注销,在_Layouts下的singout.aspx页面,就是一小段JS,如下所示,在点注销时,会转到这个页面上:
function _spBodyOnLoad()
{
try
{
document.execCommand("ClearAuthenticationCache");
}
catch (e) {}
window.close();
}
曾经在OTEC上看到一哥们写的一个webpart,其实也就是一段JS,其实仅仅是想实现这段脚本的话,实在是没有必要搞一个webpart,个人原则,能用JS不用后台代码,能用自定义控件就不用Webpart,呵呵,JS代码如下所示:
<script language="JavaScript" type="text/javascript">
<!--
var onerror = stopError;
function stopError()
{
return true;
}
if (navigator.appVersion.indexOf("MSIE") > 0)
{
try
{
var oElement = document.getElementById("idButtonLogoff");
alert('strike ' + oElement.innerHTML);
//oElement.style.display = "block";
}
catch (e) { }
}
function Logoff()
{
try
{
if (navigator.appVersion.indexOf("MSIE 6.0") > 0)
{
document.execCommand("ClearAuthenticationCache","false");
alert('You have been logged off from this Web site. Note that if you run Internet Explorer 6.0 without Service Pack 1 you need to close all browser windows in order to complete the log off process.');
self.location.href = ".";
}
else if ((navigator.appVersion.indexOf("MSIE 6.0") > 0 || navigator.appVersion.indexOf("MSIE 5.0") > 0 || navigator.appVersion.indexOf("MSIE 5.5") > 0))
{
alert('Note that if you run Internet Explorer 5.x you need to close all browser windows in order to complete the log off process.');
}
else
{
alert("This feature requires Internet Explorer 6.0 Service Pack 1 or above.");
}
}
catch (e)
{
alert("This feature requires Internet Explorer 6.0 Service Pack 1 or above.");
}
}
//-->
</script>
<p>
<div align="center" style="display: block;" id="idButtonLogoff">
<input type="button" value="Logoff" onclick="Logoff()" />
</div>
</p>
有兴趣的朋友就研究一下吧。