-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.html
More file actions
63 lines (54 loc) · 1.55 KB
/
test.html
File metadata and controls
63 lines (54 loc) · 1.55 KB
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
62
63
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Tests | WhyNotOIB</title>
</head>
<body>
<div class="ui container">
<h1 class="ui header">这是一个测试页面。</h1>
<div id="results">
未检测到相关浏览器。
</div>
</div>
<script src="whynotoib.js"></script>
<script>
let ua = navigator.userAgent;
let uaList = [
/(M|m)icro(M|m)essenger/,
/TIM\//,
/QQ\//
];
let objectList = [
"WeixinJSBridge"
]
let eventList = [
"WeixinJSBridgeReady"
]
// Execution
if (searchObject() || searchUa()) {
showOIB();
} else {
for (let i of eventList) document.addEventListener(i, () => { showOIB(); })
}
// Functions
function searchObject() {
for (let i of objectList) {
if (window[i]) return true;
}
return false;
}
function searchUa() {
for (let i of uaList) {
if (ua.search(i) !== -1) return true;
}
return false;
}
function showOIB() {
document.getElementById('results').innerHTML = `已检测到相关浏览器。<br>由于 CORS,在本地测试时可能不会看到浮动窗口。`;
}
</script>
</body>
</html>