function randomString( len ) {
// A random string of length 'len' made up of alphanumerics.
var out = '';
for (var i=0; i<len; i++) {
var random_key = 48 + Math.floor(Math.random()*42); //0-9,a-z
out += String.fromCharCode( random_key );
}
window.alert(out);
return out;
}
As far as I can tell the result of String.fromCharCode
is system and/or browser dependent. All the workarounds I've seen are for when you are actually capturing keycodes, not generating them. Is there a more reliable way to do this (like converting from ASCII codes?).