Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Destroy sticky headers
/*
* Find sticky header elements annoying? Well delete them with this
*
* inspired by https://www.ghacks.net/2018/08/16/remove-anything-that-is-sticky-on-websites/
* improved (IE9, all recent chrome, mozilla, mobile browsers) using information from:
*
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
* - https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
* - https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
*
*/
[].slice.call(document.body.querySelectorAll('*')).forEach(function(element) {
if (["sticky", "fixed"].indexOf(getComputedStyle(element).position) >= 0) {
element.parentNode.removeChild(element);
}
});
javascript:(function () {
var i, elements = document.querySelectorAll('body *');
for (i = 0; i < elements.length; i++) {
if (["sticky", "fixed"].includes(getComputedStyle(elements[i]).position)) {
elements[i].parentNode.removeChild(elements[i]);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.