//获取指定长度的随机字符串(function (len) { var i, e, str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", res = ""; for (i = 0; i < len; i ++) { res += str.charAt(Math.floor(Math.random() * str.length)); } alert(res);}(10));