简体   繁体   English

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

[英]JavaScript: how to generate UUID for Internet Explorer 9?

Does anyone know how to generate UUID/GUID for Internet Explorer? 有谁知道如何为Internet Explorer生成UUID / GUID?

I have code from Broofa at: http://www.broofa.com/2008/09/javascript-uuid-function/ 我有Broofa的代码,网址为: http ://www.broofa.com/2008/09/javascript-uuid-function/

this works fine on almost all the browsers except IE 9. 在IE 9以外的几乎所有浏览器上都可以正常工作。

this is how I do it: 这是我的方法:

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"
    };
} ();

now you can do: 现在您可以执行以下操作:

Guid.NewGuid();  // new uuid
Guid.Empty;      // empty uuid

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 生成表的 javascript 在 Chrome 上工作,但在 Internet Explorer 上失败。 如何? - The javascript to generate a table works on Chrome but fails on Internet Explorer. HOW? 生成随机 uuid Javascript - generate Random uuid Javascript 如何用JavaScript显示“该网站需要Internet Explorer”? - How to show “This website needs internet explorer” with JavaScript? 如何在Internet Explorer 9或10中安装JavaScript? - How to install JavaScript in Internet Explorer 9 or 10? 如何在Internet Explorer中暂停JavaScript执行? - How to pause JavaScript execution in Internet Explorer? 如何在Internet Explorer中使用JavaScript设置Cookie - How to set cookie using javascript in Internet Explorer 如何在Internet Explorer 7中获得缩放级别? (JavaScript的) - How to get zoom level in Internet Explorer 7? (javascript) 如何使用Javascript重现Internet Explorer Basic身份验证 - How to reproduce Internet Explorer Basic authentication with Javascript 如何使textContent在Internet Explorer 8(JavaScript)中工作 - How to get textContent to work in Internet Explorer 8 (JavaScript) 如何将JavaScript打包为.NET Internet Explorer 9插件? - How to package JavaScript as a .NET Internet Explorer 9 Plugin?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM