MediaWiki:Common.js: различия между версиями
Перейти к навигации
Перейти к поиску
Нет описания правки |
Нет описания правки |
||
| Строка 4: | Строка 4: | ||
/* let divBanner = document.createElement("div"); | /* let divBanner = document.createElement("div"); | ||
divBanner.textContent = "Banner"; | divBanner.textContent = "Banner"; */ | ||
let divBanner = null; | let divBanner = null; | ||
return divBanner; | return divBanner; | ||
} | } | ||
Версия от 18:08, 9 апреля 2024
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */
function assembleBanner() {
/* let divBanner = document.createElement("div");
divBanner.textContent = "Banner"; */
let divBanner = null;
return divBanner;
}
function insertBeforeFirstH1(domElement) {
// Find the first <h1> element on the page
var firstH1 = document.querySelector('h1');
// Check if the <h1> element exists
if (firstH1) {
// Insert the given DOM element before the first <h1> element
firstH1.parentNode.insertBefore(domElement, firstH1);
} else {
// If there is no <h1> element, you could append it to the body or handle as needed
console.log('No <h1> element found on the page.');
}
}
insertBeforeFirstH1(null);