-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhtml-tests.html
More file actions
65 lines (54 loc) · 1.96 KB
/
html-tests.html
File metadata and controls
65 lines (54 loc) · 1.96 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
64
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hyperlink Buttons</title>
<link rel="stylesheet" href="custompagestyle.css" type="text/css"/>
</head>
<body>
<h1>HTML Tests</h1>
<div class="container">
<a href="https://html5test.com" class="nav-button" id="button1" tabindex="0">
HTML Test
</a>
</div>
<!-- Go Back Link -->
<a href="#" onclick="history.back(); return false;" class="back-link" tabindex="0" id="backLink">
← Go Back to Previous Page
</a>
<script>
// Focus on the first button when the page loads
window.onload = function() {
document.getElementById('button1').focus();
};
const backgroundColor = "#FFFFFF"; // White background
document.body.style.backgroundColor = backgroundColor;
// Keyboard navigation functionality
document.addEventListener('keydown', function(e) {
const focusedElement = document.activeElement;
let nextElement = null;
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
e.preventDefault(); // Prevent scrolling the page
}
if (e.key === 'ArrowDown') {
if (focusedElement.id === 'button1') {
nextElement = document.getElementById('backLink');
}
} else if (e.key === 'ArrowUp') {
if (focusedElement.id === 'backLink') {
nextElement = document.getElementById('button1');
}
}
if (nextElement) {
nextElement.focus();
}
if (e.key === 'Enter') {
if (focusedElement.id === 'button1') {
window.location.href = 'https://html5test.com';
}
}
});
</script>
</body>
</html>