2023-06-30 16:00:14 +00:00
|
|
|
<!DOCTYPE html><html><head>
|
|
|
|
<!----------------------------------------------------------------------------->
|
|
|
|
|
|
|
|
<meta charset="UTF-8" />
|
|
|
|
<meta name="viewport" content="initial-scale=1,width=device-width" />
|
|
|
|
<link rel="stylesheet" href="test.css" />
|
|
|
|
|
|
|
|
<!----------------------------------------------------------------------------->
|
|
|
|
</head>
|
|
|
|
<body onload="main()"><header>
|
|
|
|
<!----------------------------------------------------------------------------->
|
|
|
|
|
|
|
|
<h1>Tabs</h1>
|
|
|
|
<ul>
|
|
|
|
<li><a href="test.html">test.html</a></li>
|
|
|
|
<li><a href="test.html?tab=2/3">test.html?tab=2/3</a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<!----------------------------------------------------------------------------->
|
|
|
|
</header><main>
|
|
|
|
<!----------------------------------------------------------------------------->
|
|
|
|
|
|
|
|
<div class="tabs">
|
|
|
|
<input type="radio" id="tab/1" name="tab" onclick="update(id)">
|
|
|
|
<label for="tab/1">Tab: 1</label>
|
|
|
|
<div>
|
|
|
|
<div class="tabs">
|
|
|
|
<input type="radio" id="tab/1/1" name="tab/1" onclick="update(id)">
|
|
|
|
<label for="tab/1/1">Tab: 1 / 1</label>
|
|
|
|
<div>Tab: One / One</div>
|
|
|
|
<input type="radio" id="tab/1/2" name="tab/1" onclick="update(id)">
|
|
|
|
<label for="tab/1/2">Tab: 1 / 2</label>
|
|
|
|
<div>Tab: One / Two</div>
|
|
|
|
<input type="radio" id="tab/1/3" name="tab/1" onclick="update(id)">
|
|
|
|
<label for="tab/1/3">Tab: 1 / 3</label>
|
|
|
|
<div>Tab: One / Three</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<input type="radio" id="tab/2" name="tab" onclick="update(id)">
|
|
|
|
<label for="tab/2">Tab: 2</label>
|
|
|
|
<div>
|
|
|
|
<div class="tabs">
|
|
|
|
<input type="radio" id="tab/2/1" name="tab/2" onclick="update(id)">
|
|
|
|
<label for="tab/2/1">Tab: 2 / 1</label>
|
|
|
|
<div>Tab: Two / One</div>
|
|
|
|
<input type="radio" id="tab/2/2" name="tab/2" onclick="update(id)">
|
|
|
|
<label for="tab/2/2">Tab: 2 / 2</label>
|
|
|
|
<div>Tab: Two / Two</div>
|
|
|
|
<input type="radio" id="tab/2/3" name="tab/2" onclick="update(id)">
|
|
|
|
<label for="tab/2/3">Tab: 2 / 3</label>
|
|
|
|
<div>Tab: Two / Three</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2023-06-30 17:20:26 +00:00
|
|
|
function check(tab) {
|
|
|
|
const tabs = tab.split('/')
|
|
|
|
let path = 'tab'
|
|
|
|
for (tab of tabs) {
|
|
|
|
path = `${path}/${tab}`
|
|
|
|
document.getElementById(path).checked = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function push(tab) {
|
|
|
|
const tb = tab.split('/').slice(1).join('/')
|
|
|
|
window.history.pushState(null, null, `?tab=${tb}`)
|
|
|
|
}
|
2023-06-30 16:00:14 +00:00
|
|
|
function update(id) {
|
2023-06-30 17:20:26 +00:00
|
|
|
push(id)
|
2023-06-30 16:00:14 +00:00
|
|
|
}
|
|
|
|
function main() {
|
2023-06-30 17:20:26 +00:00
|
|
|
const tab = (new URL(document.location)).searchParams.get('tab')
|
2023-06-30 16:00:14 +00:00
|
|
|
if (tab) {
|
2023-06-30 17:20:26 +00:00
|
|
|
check(tab)
|
|
|
|
} else {
|
|
|
|
check('1/1')
|
|
|
|
push('tab/1/1')
|
2023-06-30 16:00:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!----------------------------------------------------------------------------->
|
|
|
|
</main></body></html>
|