MediaWiki:Common.js: различия между версиями
Перейти к навигации
Перейти к поиску
Нет описания правки |
Нет описания правки |
||
| Строка 1: | Строка 1: | ||
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */ | /* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */ | ||
console.log("test"); | console.log("test"); | ||
function assembleBanner() { | |||
let divBanner = document.create Element("div"); | |||
divBanner.texContent = "Banner"; | |||
} | |||
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.'); | |||
} | |||
} | |||
Версия от 17:54, 9 апреля 2024
/* Размещённый здесь код JavaScript будет загружаться пользователям при обращении к каждой странице */
console.log("test");
function assembleBanner() {
let divBanner = document.create Element("div");
divBanner.texContent = "Banner";
}
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.');
}
}