参考:http://blog.csdn.net/forlong401/article/details/7580147 (GUID与UUID区别)
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript">
// JS生成UUID
//此函数生成UUID样式为af22-3fa8-4028-8dea-30a2
function getUUID() {
return 'xxxx-xxxx-xxxx-xxxx-xxxx'.replace(/[xy]/g, function(c) {
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
alert("生成UUID为:"+getUUID());
</script>
</body>
</html>