日期:2014-05-16  浏览次数:20325 次

javascript创建GUID
function NewGuid(bOrg)
{
   try
   {
    var sGuid=new ActiveXObject('scriptlet.typelib').GUID
   } 
   catch(e)
   { 
    var sGuid=fGuidCst();
   }
   
   if(bOrg) return sGuid;
   return (sGuid+'').replace(/\{|\}/g,'');
   
   function fGuidCst()
   {
    var sGuid='';
    for(var i=1; i<=32; i++)
    {
     var nNum=0;
     nNum=parseInt(Math.random()*16);
     sGuid+=nNum.toString(16);
     if(i==8||i==12||i==16||i==20)sGuid+='-';
    }
    return '{'+sGuid.toUpperCase()+'}';
   }
}