由于模版页比较长,这里只登出AJAX代码部分,即<Body>标签前面的部分
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script type="text/javascript" language="javascript">
//创建适用用与多种浏览器的XMLHttpRequest对象的函数
function getXMLRequester( ){
var xmlhttp_request = false;
try{
if( window.ActiveXObject ){
for( var i = 5; i; i-- ){
try{
if( i == 2 ){xmlhttp_request=newActiveXObject("Microsoft.XMLHTTP");
}else{xmlhttp_request = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0");
xmlhttp_request.setRequestHeader("Content-Type","text/xml");xmlhttp_request.setRequestHeader("Content-Type","gb2312");
}
break;}
catch(e){
xmlhttp_request = false;
}
}
}else if( window.XMLHttpRequest ){
xmlhttp_request = new XMLHttpRequest();
if (xmlhttp_request.overrideMimeType) {
xmlhttp_request.overrideMimeType('text/xml');
}
}
}
catch(e){
xmlhttp_request = false;
}
return xmlhttp_request ;
}
function IDRequest() {
//定义收到服务器的响应后需要执行的JavaScript函数
url='CheckLogin.aspx'//定义网址参数
//alert(url);
xmlhttp_request=getXMLRequester();//调用创建XMLHttpRequest的函数
xmlhttp_request.onreadystatechange = doContents;//调用doContents函数
xmlhttp_request.open('POST', url, true);
xmlhttp_request.send(null);
}
function doContents() {
if (xmlhttp_request.readyState == 4) {// 收到完整的服务器响应
if (xmlhttp_request.status == 200) {//HTTP服务器响应的值OK
var str = xmlhttp_request.responseText;//将服务器返回的字符串写到页面中ID为message的区域
if(str.length>583)
{
//self.location="../login.aspx";
location.href='../Login.aspx';
}
} else {
alert(http_request.status);
}
}
}
IDRequest();
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>$Chapter$-->>$Order$-->>$Title$</title>
<link href="../StyleSheet.css" rel="stylesheet" type="text/css" />
</head>