html 通过ajax进行权限控制

html.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<SCRIPT language=javascript src="down.js"
type=text/javascript></SCRIPT>
  <html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
  <title>$Chapter$-->>$Order$-->>$Title$</title>  </head>
 <a href="javascript:check()">yy</a><div  id='show'></div>

down.js


function check()  {
//var username=document.getElementById("username");
var url = "level.php";
 
 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

 xmlHttp.open('post', url, true);
 xmlHttp.onreadystatechange = function(){
 if (xmlHttp.readyState == 4) {
 //alert(xmlHttp.responseText);
//document.getElementById("show").innerHTML =decodeURI(xmlHttp.responseText);
 if (xmlHttp.responseText==1){
alert("您的权限不够!请登录。")
 }
  if (xmlHttp.responseText==0){
 window.open("说明生成静态html的方法.rar","new","");
 }
}
 
 }
 xmlHttp.setRequestHeader("Content-Type","text/html;charset=utf-8");
 xmlHttp.send(null);
}

level.php

<?
echo '1';

?>

通过这几个页面就可以实现静态页面的确权限控制。

原文地址:https://www.cnblogs.com/fengju/p/6174094.html