diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-11-24 00:53:00 +0100 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-11-24 00:53:00 +0100 |
| commit | 1efc3082a3ec64e71ab4a6b5ed290d9473e77bc9 (patch) | |
| tree | 4371a3e3a09f63c5bec6ac9047d6884a661e853d | |
| parent | b908b8959658676faff68677d4466d18a141b9f3 (diff) | |
| download | quatuorbellefeuille.com-1efc3082a3ec64e71ab4a6b5ed290d9473e77bc9.tar.xz | |
DTRT when loading a URL with an anchor
| -rw-r--r-- | actualités.html | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/actualités.html b/actualités.html index 925d167..bc033fe 100644 --- a/actualités.html +++ b/actualités.html @@ -224,20 +224,23 @@ </div> <!-- TODO: prevent scroll when clicking on overflowing details --> - <!-- TODO: check URL for anchor and auto-enable --> <script> var detailsStyle = document.createElement('style'); document.head.appendChild(detailsStyle); detailsStyle.sheet.insertRule('.details:not(.active) {display:none}'); + var anchor = document.location.hash; + if (anchor.match(/#concert-[0-9]/)) + document.querySelector(anchor).classList.add('active'); + document.querySelectorAll('.event a').forEach((link) => { - link.onclick = function() { + link.addEventListener('click', function() { var prev = document.querySelector('.details.active'); if (prev) prev.classList.remove('active'); var id = link.attributes['href'].value; document.querySelector(id).classList.add('active'); - } + }); }); </script> |
