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