User:TripleShortOfACycle/global.js
Appearance
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
// Get the header
var headerContainer = document.getElementById("mw-header-container");
var header = document.getElementById("mw-header");
// Get the offset position of the navbar
var sticky = headerContainer.offsetTop;
// Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
function myFunction() {
if (window.pageYOffset > sticky) {
// headerContainer.removeChild(header);
headerContainer.style.display = "None";
} else {
headerContainer.style.display = "";
}
}