JavaScript: how to generate UUID for Internet Explorer 9?
Does anyone know how to generate UUID/GUID for Internet Explorer?
I have code from Broofa at: http://www.broofa.com/2008/09/javascript-uuid-function/
this works fine on almost all the browsers except 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
链接地址: http://www.djcxy.com/p/91428.html