tweak JS
This commit is contained in:
parent
3c67bd293d
commit
7eecacb787
18
cor.html
18
cor.html
|
@ -9,18 +9,26 @@
|
||||||
<body>
|
<body>
|
||||||
<script src="assets/script.js"></script>
|
<script src="assets/script.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function switchTab() {
|
function setHash() {
|
||||||
window.location.hash = this.id;
|
window.location.hash = this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
onload = function () {
|
function switchTab() {
|
||||||
if (window.location.hash.substring(1)) {
|
hash = window.location.hash.substring(1);
|
||||||
document.getElementById(window.location.hash.substring(1)).checked = true;
|
if (hash) {
|
||||||
|
document.getElementById(hash).checked = true;
|
||||||
|
} else {
|
||||||
|
document.getElementById('study').checked = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onload = function () {
|
||||||
|
switchTab();
|
||||||
|
window.onhashchange = switchTab;
|
||||||
|
|
||||||
var tabs = document.getElementsByName('tabs');
|
var tabs = document.getElementsByName('tabs');
|
||||||
for (var i = 0; i < tabs.length; i++) {
|
for (var i = 0; i < tabs.length; i++) {
|
||||||
tabs[i].onclick = switchTab;
|
tabs[i].onclick = setHash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue