Related Blog Posts

Keyboard Event Handling with FBJS
FBJS event handling does not follow the default Facebook JavaScript event handling model exactly. Facebook re-writes the event object as a far more limited o...

'Tis the Season of the New TV
Televisions are always a hot topic for holiday purchases and this year is no different. I was reviewing my Google Analytics numbers for AF-Design this morning a...

So That's What Broke!
MySpace has a good post explaining why you can't use relative links within OpenSocial applications. If you're building for the OpenSocial container and trying ...


Just for Fun > JavaScript >

JavaScript UUID Class

While a true implementation of UUID is not possible yet, this implementation provides reasonable uniqueness.

The UUID generated is only located in time, because of sandbox issues in JavaScript, it is not able to locate geo-spacially and so subsitutes a series of random numbers to ensure uniqueness where NIC addresses should be used.

If your looking for a Microsoft dependent solution - you can use ActiveX code to create a Microsoft GUID. However, it's always best to write code for any platform when possible.

Download

These files only include the .js include file. Documentation currently is only available at this site.

Usage

Simply include the class file in your header.

<script type="text/javascript" src="uuid.js"></script>

Next create a new instance of UUID. The class returns a string so simply set that to your variable and your done.

var id = new UUID();

Known Issues

  1. JavaScript can not reliably detect the browsers IP address (in a platform independent way) and the NIC for the machine, a random string of numbers must be used to generate the final sequence.
  2. Some implementations of JavaScript do not use 60bit date fields. While this is less critical than the NIC issue, it's still important to mention.

Real time examples

The following examples were created using the UUID class just now!

Let us know...

If your able to improve this class or are actively using it.

© 1998-2009 AF-Design, All rights reserved.