1 var getLocalhost = "xxxxx"; // ip名
2 /**
3 * 判断当前页面是否是login页面
4 * 如果当前页面中sessionStorage.UserSession不存在
5 * 跳转到login页面
6 */
7 if(window.location.pathname.indexOf("login.html") == -1) {
8 if(!sessionStorage.ADMINUSERSESSION) {
9 var num = Math.ceil(Math.random() * 100000000);
10 window.location.href = "login.html?_hbt=" + num;
11 }
12 }
13 /**
14 * 获取url后面的参数
15 */
16 function getRequest() {
17 var url = location.search; //获取url中"?"符后的字串
18 var theRequest = new Object();
19 if(url.indexOf("?") != -1) {
20 var str = url.substr(1);
21 strs = str.split("&");
22 for(var i = 0; i < strs.length; i++) {
23 theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
24 }
25 }
26 return theRequest;
27 }
28 // 使用方法,获取url参数为id的值
29 // getRequest().id;
30 /**
31 * 退出登录
32 */
33 function quit() {
34 sessionStorage.removeItem('ADMINUSERSESSION');
35 var num = Math.ceil(Math.random() * 100000000);
36 window.location.href = "login.html?_hbt=" + num;
37 }