//判断一个汉字等于两个字符 function getByteLen(val) { var len = 0; for (var i = 0; i < val.length; i++) { var a = val.charAt(i); if (a.match(/[^\x00-\xff]/ig) != null) { len += 2; } else { len += 1; } } return len; }
//解析url参数 function QueryString() { var name, value, i; var str = location.href; var num = str.indexOf("?") str = str.substr(num + 1); var arrtmp = str.split("&"); for (i = 0; i < arrtmp.length; i++) { num = arrtmp[i].indexOf("="); if (num > 0) { name = arrtmp[i].substring(0, num); value = arrtmp[i].substr(num + 1); this[name] = value; } } } //调用时使用 var Request = new QueryString(); var param= Request["param"];
/*****缓存读写******// //写缓存 function SetItem(key, data) {localStorage.setItem(key, data);} //读缓存 function GetItem(key) { return localStorage.getItem(key);}