common-function-lib.js
1 /*产生随机颜色*/ 2 function randomColor() { 3 var rand = Math.floor(Math.random() * 0xFFFFFF).toString(16); 4 if (rand.length == 6) { 5 return rand; 6 } else { 7 return randomColor(); 8 } 9 }10 /* 获取url中"?"符后的参数 */11 function getRequest() {12 var url = location.search; // 获取url中"?"符后的字串13 var theRequest = new Object();14 if (url.indexOf("?") != -1) {15 var str = url.substr(1);16 strs = str.split("&");17 for ( var i = 0; i < strs.length; i++) {18 theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);19 }20 }21 return theRequest;22 }23 /*生成验证码*/24 function createCode() {25 var code = "";26 var codeLength = 4;//验证码的长度 27 var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',28 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');29 for (var i = 0; i < codeLength; i++) {30 var index = Math.floor(Math.random() * 36);31 code += random[index];32 }33 }
新闻热点
疑难解答