var util = {}; util.setLSItem = function (key, value) { localStorage.setItem(key, value); }; util.getLSItem = function(key){ return localStorage.getItem(key); }; util.setSSItem = function (key, value) { sessionStorage.setItem(key, value); }; util.getSSItem = function (key) { return sessionStorage.getItem(key); }; util.isVal = function (val){ if(val == null || val == undefined || val == "" || val==NaN){ return false; }else{ return true; } }; util.getQueryString = function() { var url = location.search; //获取url中"?"符后的字串 var theRequest = new Object(); if (url.indexOf("?") != -1) { var str = url.substr(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++) { theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]); } } return theRequest; }; // 全局方法 jumpto,goback function jumpto(to) { var href = location.href; var index = href.lastIndexOf("/"); var starthref = href.substr(0, index); var endhref = href.substr(index+1,href.length); var type = to.substr(0,to.indexOf(".")); //记录上级地址 localStorage.setItem("page"+type, endhref); href = starthref + "/" + to; location.href = href; }; function goback(){ var href = location.href; var index = href.lastIndexOf("/"); var endhref = href.substr(index+1,href.length); var starthref = href.substr(0, index); var type = endhref.substr(0,endhref.indexOf(".")); var from = localStorage.getItem("page"+type); if(from==null || from ==undefined){ window.location.href="index.html"; return; } href = starthref + "/" + from; window.location.href=href; }; Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + 1, //月份 "d+": this.getDate(), //日 "h+": this.getHours(), //小时 "m+": this.getMinutes(), //分 "s+": this.getSeconds(), //秒 "q+": Math.floor((this.getMonth() + 3) / 3), //季度 "S": this.getMilliseconds() //毫秒 }; if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; }