码迷,mamicode.com
首页 > 编程语言 > 详细

JavaScript js生成GUID

时间:2014-10-10 19:11:54      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   java   sp   

function generateUUID(){
    var d = new Date().getTime();
    var uuid = ‘xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx‘.replace(/[xy]/g, function(c) {
        var r = (d + Math.random()*16)%16 | 0;
        d = Math.floor(d/16);
        return (c==‘x‘ ? r : (r&0x7|0x8)).toString(16);
    });
    return uuid;
};

我选用的是上面这个

原文地址:http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript 

JavaScript js生成GUID

标签:style   blog   http   color   io   os   ar   java   sp   

原文地址:http://www.cnblogs.com/niaowo/p/4016328.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!