-
Notifications
You must be signed in to change notification settings - Fork 0
/
programmatic-focus.html
32 lines (32 loc) · 1.01 KB
/
programmatic-focus.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
<!DOCTYPE html>
<html>
<body>
<h1>Focus Steal Sample</h1>
<p>Click on the "Load frame" button below to see focus being stole by the iframed page. You will see the focus rect move into the frame after it loads.</p>
<p>Click on the "Focus frame" button below to programmatically move focus to the iframed page. You should see the focus rect move into the frame.</p>
<button onclick="loadFrame()">Load frame</button>
<button onclick="focusFrame()">Focus frame</button>
<iframe id="frame" allow="focus-without-user-activation 'none'" width="100%" height="300"></iframe>
<script>
function loadFrame() {
document.getElementById("frame").src = "./programmatic-focus-iframe.html";
}
function focusFrame() {
document.getElementById("frame").focus();
}
</script>
<style>
body {
font-family: Arial, sans-serif;
}
button {
font-size: 1.5em;
padding: 0.5em;
margin-bottom: 0.5em;
}
button:focus {
outline: 2px solid blue;
}
</style>
</body>
</html>