I am building a footer and of the options of the footer is "home" and when it's clicked it should scroll smoothly up and that works on my pc, but what I noticed is that it doesn't work on IOS devices. I read that the css line: HTML{ scroll-behavior: smooth;} does not work on IOS devices
<!--html code<a class="link-1" onclick="test()" href="#">Home</a>
I read a lot of the forms here on Stack Overflow. I tried a lot of thing such as:
window.scrollTo({ top: 900, behavior: 'smooth' })
}
or using css
overflow:scroll
-webkit-overflow-scrolling: touch;
or
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
But nothing worked. It just jumps to the top. I'm slowly running out of ideas.
Any ideas? Thanks!