DEV Community

Discussion on: Making a 'Back to Top' button without Javascript

Collapse
 
rtivital profile image
Vitaly Rtishchev

well, it kind of works but messes up with browser history, user will have to click back button twice which is a bad UX, so just, please, stick to the js solution instead of link

Collapse
 
futureistaken profile image
R Z

Anyway, it's a good idea if you don't want to use onScroll event. You just can add a little bit JS to replace the link with a button.

Collapse
 
rtivital profile image
Vitaly Rtishchev

Yep, that's what I've meant, when replacing js with css, do not forget about the UX

Collapse
 
jackherizsmith profile image
Jack

Hey Vitaly! Thanks for your comment. What browser are you using? href="#" just navigates to the top of page, it doesn't add to the history in the browser which I should have mentioned in the article, I'll update that now. If you have any other reasons to suggest using JS on top of CSS I'd love to hear them.

Collapse
 
capsule profile image
Thibaut Allender

The question is more, what browser doesn't add it to the history? Both the latest Firefox and Chrome add # to the history.