JavaScript:如何为Internet Explorer 9生成UUID?

有谁知道如何为Internet Explorer生成UUID / GUID?

我有来自Broofa的代码:http://www.broofa.com/2008/09/javascript-uuid-function/

这对几乎所有浏览器除了IE 9都能正常工作。


这是我如何做到的:

window.Guid = function () {
    function part() {
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1).toUpperCase();
    };

    return {
        NewGuid: function () { return (part() + part() + "-" + part() + "-" + part() + "-" + part() + "-" + part() + part() + part()); },
        Empty: "00000000-0000-0000-0000-000000000000"
    };
} ();

现在你可以这样做:

Guid.NewGuid();  // new uuid
Guid.Empty;      // empty uuid
链接地址: http://www.djcxy.com/p/91427.html

上一篇: JavaScript: how to generate UUID for Internet Explorer 9?

下一篇: How to make a marquee cycle once at a button click?