MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus Populus DE
Zur Navigation springenZur Suche springenThk (Diskussion | Beiträge) Markierung: Rückgängigmachung |
Thk (Diskussion | Beiträge) |
||
Zeile 1: | Zeile 1: | ||
console.log(window); |
console.log(window); |
||
+ | |||
+ | var theOnHashChangedListener = function(){ |
||
+ | console.log("hash changed"); |
||
+ | var prev = document.querySelector('#toc a.selected'); |
||
+ | if (prev !== null) { |
||
+ | prev.classList.remove('selected'); |
||
⚫ | |||
+ | |||
+ | var curr = document.querySelector('#toc a[href="#' + window.location.hash + '"]'); |
||
+ | if (curr !== null) { |
||
+ | curr.classList.add('selected'); |
||
+ | } |
||
+ | } |
||
window.addEventListener( |
window.addEventListener( |
||
"hashchange", |
"hashchange", |
||
+ | theOnHashChangedListener |
||
⚫ | |||
− | false |
||
); |
); |
Version vom 16. Juli 2023, 10:24 Uhr
console.log(window); var theOnHashChangedListener = function(){ console.log("hash changed"); var prev = document.querySelector('#toc a.selected'); if (prev !== null) { prev.classList.remove('selected'); } var curr = document.querySelector('#toc a[href="#' + window.location.hash + '"]'); if (curr !== null) { curr.classList.add('selected'); } } window.addEventListener( "hashchange", theOnHashChangedListener );