通过window.crypto.getRandomValues获得一个大于零的随机数

window.crypto.getRandomValues(new Uint32Array(1))[0];

浏览器支持情况如下:

IE: no
IE Mobile: no

Firefox24+

Firefox Mobile: will be in 21

Safari: from 3.1

Safari Mobile: from iOS 6

Chrome: from 11

Chrome for Mobile: from 23
Android browser (before 4.0 as replaced with Chrome): no

Opera: no (though will probably get it when moving to WebKit)

Opera Mobile: no
Opera Mini: no
原文地址:https://www.cnblogs.com/rubylouvre/p/3462457.html