Hi @berti09
In the Website Custom Javascript section something like this should work:
window.onscroll = function() {myFunction()};
function myFunction() {
if (document.body.scrollTop > 10 || document.documentElement.scrollTop > 10) {
document.getElementById("simple-banner").setAttribute("style", "display:none;");
} else {
document.getElementById("simple-banner").setAttribute("style", "display:block;");
}
}
Thread Starter
Anonymous User 15363885
(@anonymized-15363885)
Thanks for this.
I was trying to get it to stay hidden once a user scrolls down, rather than appear about again when they scroll up, like some cookie banners do…
Is this easy to achieve?
-
This reply was modified 6 years ago by
Anonymous User 15363885.
Shouldn’t be too hard to implement. You can look here, https://stackoverflow.com/questions/14573223/set-cookie-and-get-cookie-with-javascript, for an example.
Essentially once the code is set up you would do something like
window.onscroll = function() {myFunction()};
function myFunction() {
if (document.body.scrollTop > 10 || document.documentElement.scrollTop > 10) {
document.getElementById("simple-banner").setAttribute("style", "display:none;");
setCookie('simple-banner-cookie','testcookie',7);
}
}
var x = getCookie('simple-banner-cookie');
if (x) {
document.getElementById("simple-banner").setAttribute("style", "display:none;");
}