Re:No, I don’t want to sign up for your newsletter
by metadat on Monday April 24, 2023 @09:57AM
(#35687722)
This sounds great! Can you share the code?
[ Parent
| on HN ]
Re:No, I don’t want to sign up for your newsletter
by jabroni_salad on Monday April 24, 2023 @10:04AM
(#35687818)
NTHNer but here is the one I use. It's old but it still works a treat: https://alisdair.mcdiarmid.org/kill-sticky-headers/
(function () {
var i, elements = document.querySelectorAll('body *');
for (i = 0; i < elements.length; i++) {
if (getComputedStyle(elements[i]).position === 'fixed') {
elements[i].parentNode.removeChild(elements[i]);
}
}
})();
Re:No, I don’t want to sign up for your newsletter
by err4nt on Monday April 24, 2023 @02:27PM
(#35691281)
I rewrote this to be a little more succinct:
document.querySelectorAll('body *').forEach(tag =>
getComputedStyle(tag).position === 'fixed' && tag.remove()
);
- you can use `forEach()` on the NodeList that `querySelectorAll()` returns- you can use `remove()` directly on the DOM node you want to remove
Re:No, I don’t want to sign up for your newsletter
by Xeanort on Wednesday April 26, 2023 @04:39PM
(#35719657)
Here for an improved version: https://github.com/t-mart/kill-sticky