master will be 4.0
[freeside.git] / httemplate / elements / logout.html
1 <%doc>
2
3 Example:
4
5   include( '/elements/logout.html');
6   This is the <a href="javascript:void()" onClick="logout();">logout</a> link.
7
8 </%doc>
9 <SCRIPT TYPE="text/javascript">
10
11   function logout() {
12     // count args; build URL
13     var url = "<% $fsurl. 'loginout/logout.html' %>";
14
15     var xmlhttp = rs_init_object();
16     xmlhttp.open("GET", url, false, "magic", "notyet");
17     xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
18     xmlhttp.send(null);
19
20     if (xmlhttp.readyState != 4) {
21       alert("Logout failed: readyState is " + xmlhttp.readyState);
22       return;
23     }
24
25     if (xmlhttp.status != 200) {
26       alert("Logout failed: status is " + xmlhttp.status);
27     } else {
28       var data = xmlhttp.responseText;
29       // alert('received response: ' + data);
30       if ( data.indexOf("<b>System error</b>") > -1 ) {
31         var w;
32         if ( w = window.open("about:blank") ) {
33           w.document.write(data);
34         } else {
35           // popup blocking?  should use an overlib popup instead 
36           alert("Error popup disabled; try disabling popup blocking to see");
37         }
38       } else {
39         window.location = "<% $fsurl. 'loginout/logout.html' %>";
40       }
41     }
42   }
43
44 </SCRIPT>