Skip to content

Instantly share code, notes, and snippets.

@Zegnat
Last active May 15, 2019 11:42
Show Gist options
  • Save Zegnat/3af4763584ebc491bd08cd32038a2484 to your computer and use it in GitHub Desktop.
Save Zegnat/3af4763584ebc491bd08cd32038a2484 to your computer and use it in GitHub Desktop.
(function handleLinksToDetails() {
var openBasedOnHash
(openBasedOnHash = function openBasedOnHash() {
const hash = window.location.hash;
if (hash.length > 1) {
const element = document.getElementById(hash.substr(1))
if (element instanceof HTMLDetailsElement && element.open === false) {
element.open = true
}
}
})()
window.addEventListener('hashchange', openBasedOnHash, false)
}())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment