`
e_soft
  • 浏览: 48763 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

ajax log out user under BASIC authentication

 
阅读更多
    <script type="text/javascript">
        function GetXmlHttpObject()
        {
            if (window.XMLHttpRequest)
              {
              // code for IE7+, Firefox, Chrome, Opera, Safari
              return new XMLHttpRequest();
              }
            if (window.ActiveXObject)
              {
              // code for IE6, IE5
              return new ActiveXObject("Microsoft.XMLHTTP");
              }
            return null;
        }

        function logoutUser() {
            //setTimeout('location.reload(true)', 1000);
            xmlhttp = GetXmlHttpObject();
            if (xmlhttp==null) {
            return;
            }
            //alert(xmlhttp);
            var url = "index.jspx";

            xmlhttp.open("GET", url, true, "dummy_user", "dummy_password");

            xmlhttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
            xmlhttp.setRequestHeader( 'Accept', 'message/x-formresult' );
            xmlhttp.send(null);
        }

        logoutUser();
    </script>


The idea is to force a request with some invalid credentials, in order to invalidate the real credentials cached by the browser.

It is working fine in IE,Firefox, Safari, Google Chrome but not in Opera.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics