首先需要在项目中加入一个很简单的js文件==> 将整个要替换成html页面的body区域内容返回回来并在html中做显示 在html里这样些<body οnlοad=t("Default.aspx")></body>==>意思就是将Default.aspx页面替换成html页面 在超连接中使用此方法 <a href="Registor.aspx" οnclick="t(Registor.aspx)">注册</a>==>将Registor.aspx替换成html页面
js文件: function t(url) { var xmlHttp; if(window.XMLHttpReqeust) { xmlHttp = new XMLHttpRequest(); } else if(window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHttp"); } xmlHttp.open("POST",url,true); xmlHttp.onreadystatechange=function() { if(xmlHttp.readystate==1) { document.body.innerHTML="<div style='padding:300px;text-align:center;'><div style='padding:30px;text-align:center;border:1px #ebebeb solid;'>页面正在加载中,请稍候.......</div></div>"; } if(xmlHttp.readystate==4) { if (xmlHttp.status==200) { document.body.innerHTML=xmlHttp.responseText; } } } xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); xmlHttp.send(null); }