-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathindex.html
More file actions
31 lines (28 loc) · 929 Bytes
/
index.html
File metadata and controls
31 lines (28 loc) · 929 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Simple Routing Example</title>
</head>
<body>
<nav>
<a href="./cdn.html">CDN</a> |
<a href="./lib.html">Lib</a> |
<a href="./worker.html">Worker</a>
</nav>
<div id="app"></div>
<script>
const routes = {
cdn: '<h2>CDN Page</h2><p>This is cdn.html content.</p>',
lib: '<h2>Lib Page</h2><p>This is lib.html content.</p>',
worker: '<h2>Worker Page</h2><p>This is worker.html content.</p>',
};
function renderRoute() {
const hash = location.hash.replace('#', '');
document.getElementById('app').innerHTML = routes[hash] || '<h2>Welcome</h2><p>Select a page.</p>';
}
window.addEventListener('hashchange', renderRoute);
window.addEventListener('DOMContentLoaded', renderRoute);
</script>
</body>
</html>