感觉原文对js生成guid理解表述不准确,固改了标题,标题是个人的理解
原文地址是:http://www.cnblogs.com/NoRoad/archive/2010/03/12/1684759.html
方法一:
//JS生成类GUIDfunction S4()
{
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
}
function NewGuid()
{
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
方法二:
function newGuid()
{
var guid = "";
for (var i = 1; i <= 32; i++){
var n = Math.floor(Math.random()*16.0).toString(16);
guid += n;
if((i==8)||(i==12)||(i==16)||(i==20))
guid += "-";
}
return guid;
}
来源:CSDN
作者:DO_DAJIANGJUN
链接:https://blog.csdn.net/XuWei_XuWei/article/details/26622125