-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser-info-2.html
61 lines (50 loc) · 1.38 KB
/
browser-info-2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>浏览器信息查询</title>
<style>
p {
font-size: medium;
}
</style>
</head>
<body onload="init()">
<h1>浏览器信息查询</h1>
<h3>User Agent:</h3>
<p id="ua"></p>
<h3>GPU信息:</h3>
<p id="renderer"></p>
<p id="vendor"></p>
<canvas id="cvs" width="640" height="480"></canvas>
</body>
<script>
function init() {
// 查询浏览器user agent
const ua = navigator.userAgent || '';
console.log(ua);
const e = document.getElementById('ua');
e.innerHTML = ua;
const canvas = document.getElementById("cvs");
canvas.addEventListener(
"webglcontextcreationerror",
(e) => {
console.log(e.statusMessage || "Unknown error");
alert(e.statusMessage || "Unknown error");
},
false,
);
const gl = canvas.getContext("webgl");
if (gl) {
const debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
if (debugInfo) {
const renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
document.getElementById('renderer').innerHTML = renderer;
const vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
document.getElementById('vendor').innerHTML = vendor;
}
}
}
</script>
</html>