- //获取url参数,正则匹配
- function getQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]); return null;
- }
- //获得字符串实际长度,中文2,英文1
- function GetLength(str) {
- var realLength = 0, len = str.length, charCode = -1;
- for (var i = 0; i < len; i++) {
- charCode = str.charCodeAt(i);
- if (charCode >= 0 && charCode <= 128) realLength += 1;
- else realLength += 2;
- }
- return realLength;
- }
复制代码 |