-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
35 lines (26 loc) · 914 Bytes
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Register a custom protocol handler</title>
</head>
<body>
<h1>Register a custom protocol handler</h1>
<script>
function randomLowercaseLetter() {
// 生成一个 [97, 122] 之间的随机数
var n = Math.floor(Math.random() * 26) + 97;
// 将生成的数字转换为字符
var c = String.fromCharCode(n);
return c;
}
function registerProtocolHandler() {
console.log("点击了");
// Register the "mycustomprotocol" protocol for the website "example.com".
navigator.registerProtocolHandler("web+github" + randomLowercaseLetter(), "https://cyzlucky.github.io/blog/?url=%s", "My Custom Protocol");
}
</script>
<button onclick="registerProtocolHandler()">Register protocol</button>
<a href="web+github:wiki">Wiki</a>
</body>
</html>