Source: http://www.broofa.com/2008/09/javascript-uuid-function/
1. Code: http://www.broofa.com/Tools/Math.uuid.js
2. Test: http://www.broofa.com/Tools/Math.uuid.htm
----------------------------------------------------
Generate UUID in JS
Call method: see the JS description.
Math. UUID (); commonly used
Math. uuidfast (); you can delete it if you don't need it.
Math. uuidcompact (); you can delete it if you don't need it.
HTML code
- <HTML>
- <Head>
- <Title> UUID test </title>
- <SCRIPT src = "UUID. js"> </SCRIPT>
- <SCRIPT src = "jquery-1.7.2.min.js"> </SCRIPT>
- <SCRIPT>
- $ (Function (){
- VaR begin = new date ();
- For (VAR I = 0; I <1000; I ++ ){
- // Math. UUID (); // operation 1000 times, 47 Ms
- // Math. uuidfast (); // operation 1000 times, 31 Ms
- // Math. uuidcompact (); // 1000 operations, 8-94 milliseconds
- // $ ("Body"). append (math. UUID () + '<br/> ');
- $ ("Body"). append (math. UUID () + '<br/> ');
- }
- VaR end = new date ();
- Alert (end. gettime ()-begin. gettime (); // 1000 702 milliseconds
- });
- </SCRIPT>
- </Head>
- <Body>
- UUID test <br/>
- </Body>