MediaWiki:Common.js: различия между версиями
User (обсуждение | вклад) Нет описания правки |
User (обсуждение | вклад) Нет описания правки |
||
| Строка 11: | Строка 11: | ||
links.forEach(function (link) { | links.forEach(function (link) { | ||
var linkhref = location.protocol + '//' + location.host + link.getAttribute('href').trim(); | var linkhref = location.protocol + '//' + location.host + link.getAttribute('href').trim(); | ||
console.log(currentPageHref + '=' + linkhref); | |||
console.log(currentPageHref + '=' + linkhref); | if (currentPageHref === linkhref) { | ||
link.closest('li').classList.add('a-current'); | |||
} | } | ||
}); | }); | ||
} | } | ||
Версия от 14:53, 15 мая 2024
if (document.readyState !== 'loading') {
myInitCode();
} else {
document.addEventListener('DOMContentLoaded', function () {
myInitCode();
});
}
function myInitCode() {
var currentPageHref = decodeURI(window.location.href);
var links = document.querySelectorAll('.custom-top-menu a');
links.forEach(function (link) {
var linkhref = location.protocol + '//' + location.host + link.getAttribute('href').trim();
console.log(currentPageHref + '=' + linkhref);
if (currentPageHref === linkhref) {
link.closest('li').classList.add('a-current');
}
});
}