Get distance from top using Document.documentElement or Document.body and Element.scrollTop.
Use Window.pageXOffset and Window.pageYOffset if they are defined, otherwise Element.scrollLeft and Element.scrollTop.
We can scroll to given element smoothly (smooth scroll) by passing behavior: ‘smooth’.
Check if ‘ontouchstart’ exists in window.
This snippet produces a smooth scrolling implementation which also allows us to customize the animation effect and duration.
Utilizing this snippet, you can add a button at the bottom of page that allows user to scroll to the top quickly.
This snippet listens for scroll events using addEventListener, sets a delayed timeout function to run a few milliseconds after the event, but with each scroll event it clears that timeout function so it doesn’t run.
Using this script, you will be able to keep your pages valid while also using the target attribute to open new windows.
An attractive news bar script. Messages are automatically rotated and displayed, with the ability to manually cycle back and forth through them. This script was created entirely using form buttons. Works in most browsers!