前端取唯一标识 UUID

// 使用工具 fingerprintjs 可以简单取到UUID

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 
 4 <head>
 5   <meta charset="UTF-8">
 6   <meta http-equiv="X-UA-Compatible" content="IE=edge">
 7   <meta name="viewport" content="width=device-width, initial-scale=1.0">
 8   <title>Document</title>
 9 </head>
10 
11 <body>
12   <input value="" id="input" style="width: 300px;" />
13   <div id="user"></div>
14   <script>
15     const fpPromise = import('https://openfpcdn.io/fingerprintjs/v4')
16       .then(e => e.load())
17     fpPromise
18       .then(fp => fp.get())
19       .then(result => {
20         const visitorId = result.visitorId
21         console.log(visitorId)
22         document.getElementById('input').value = visitorId
23         document.getElementById('user').innerHTML = window.navigator.userAgent.toLowerCase()
24       })
25   </script>
26 </body>
27 
28 </html>
View Code

 

 

 

 

 

 

.

posted @ 2024-07-07 17:10  James2019  阅读(2)  评论(0编辑  收藏  举报