I'm having an issue with HTML anchor tags not working properly in Chrome and Safari. Instead of scrolling up, the page scrolls down when clicked. Here is the HTML code I'm using:
<a id="to-top"></a>
<a class="button toTop" href="#" onclick="document.getElementById('to-top').scrollIntoView(true);return false;">Вверх</a>
And here is the JavaScript code:
var topScreen = window.pageYOffset ? window.pageYOffset : document.body.scrollTop;
var myScreen = screen.availHeight;
if(topScreen > (myScreen / 3)) {
$(".toTop").fadeTo(0, 1.0);
}
else {
$(".toTop").fadeTo(0, 0);
Also, here is the SCSS code:
.toTop {
display: none;
position: fixed;
bottom: 20px;
right: 20px;
z-index: 999999;
transition: opacity 1s ease-out;
outline: none;
&:hover {
transition-delay:0s;
}
a {
color: #fff;
text-decoration: none;
&:hover {
color: #000;
}
}
}
Something seems to be wrong. Additionally, the element remains focused after being clicked.