• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Archives for Navigation

Navigation

Smooth Scroll to the Top of the Page With JavaScript

Smooth Scroll to the Top of the Page With JavaScript

Get distance from top using Document.documentElement or Document.body and Element.scrollTop.

Navigation

Return the scroll position of the current page

Return the scroll position of the current page

Use Window.pageXOffset and Window.pageYOffset if they are defined, otherwise Element.scrollLeft and Element.scrollTop.

Navigation

Scroll to an element smoothly (smooth scroll)

Scroll to an element smoothly (smooth scroll)

We can scroll to given element smoothly (smooth scroll) by passing behavior: ‘smooth’.

Navigation

Drag to scroll

drag to scroll

This post shows you a simple way to allow users to scroll by dragging the element with vanilla JavaScript.

Navigation

Check if touch events are supported

Check if touch events are supported

Check if ‘ontouchstart’ exists in window.

Navigation

Scroll to an element smoothly

Scroll to an element smoothly

This snippet produces a smooth scrolling implementation which also allows us to customize the animation effect and duration.

Navigation

Scroll to top of the page

Scroll to top of the page

Utilizing this snippet, you can add a button at the bottom of page that allows user to scroll to the top quickly.

Navigation

Detecting when a visitor has stopped scrolling

Detecting when a visitor has stopped scrolling

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.

Navigation

Using the Target Attribute

Using the Target Attribute

Using this script, you will be able to keep your pages valid while also using the target attribute to open new windows.

Navigation

Ticker

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!

Navigation

  • Go to page 1
  • Go to page 2
  • Go to Next Page »

Primary Sidebar

FREE UPDATES!

Get the latest updates in your inbox for FREE!

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2023 JavaScriptSource.com

  • About
  • Privacy Policy
  • Submit
  • FAQ
  • Jobs For Developers
  • Contact Us