-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
46 lines (45 loc) · 1.56 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AccessKeyLabelPolyfill, Demo</title>
<link rel="stylesheet" href="./demo/styles.css" />
<script type="module" src="/src/AccessKeyLabelPolyfill.ts"></script>
</head>
<body>
<main>
<button accesskey="p" onclick="alert('Geronimooooo!')">
<u>P</u>ress me
</button>
<p></p>
</main>
<script>
// Check for browser support
var button = document.querySelector("button");
var support = document.createElement("p");
var supported = !!Object.getOwnPropertyDescriptor(
HTMLElement.prototype,
"accessKeyLabel",
);
if (supported) {
support.classList = "supported";
support.innerText =
"Your browser already supports the accessKeyLabel property, so this polyfill will not do anything here.";
} else {
support.classList = "unsupported";
support.innerText =
"Your browser does not support the accessKeyLabel property, so this polyfill will take action.";
}
button.parentNode.insertBefore(support, button.nextSibling);
// Display accesskey hint below button
document.onreadystatechange = () => {
if (document.readyState === "complete") {
var hint = document.createElement("span");
hint.innerText = button.accessKeyLabel;
button.parentNode.insertBefore(hint, button.nextSibling);
}
};
</script>
</body>
</html>