Skip to content

Commit

Permalink
Fix index.html initial button status for empty hash
Browse files Browse the repository at this point in the history
  • Loading branch information
mfiebig committed Nov 15, 2024
1 parent 3a7192d commit 1fd8e8b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@
}

window.addEventListener('load', function() {
var hash = "concept/index.html";
if (window.location.hash && window.location.hash.length > 2) {
var hash = window.location.hash.substring(1).replace('%23', '#');
document.getElementById('content').src = hash;
var links = document.querySelectorAll('#menu a');
links.forEach(link => {
if (hash.startsWith(link.getAttribute('href'))) {
link.classList.add('active');
} else {
link.classList.remove('active');
}
});
hash = window.location.hash.substring(1).replace('%23', '#');
}
document.getElementById('content').src = hash;
var links = document.querySelectorAll('#menu a');
links.forEach(link => {
if (hash.startsWith(link.getAttribute('href'))) {
link.classList.add('active');
} else {
link.classList.remove('active');
}
});
});

document.getElementById('content').addEventListener('load', function() {
Expand Down

0 comments on commit 1fd8e8b

Please sign in to comment.