• 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 Page Details

Page Details

How To Get The Current URL In JavaScript

How To Get The Current URL In JavaScript

JavaScript provides multiple ways to get the current URL of a webpage. In this article, we will discuss the most common methods to achieve this.

Page Details

Viewport Width

Viewport Width

There are two methods to get the viewport width: window.innerWidth and document.documentElement.clientWidth. The former is more accurate. The latter has better browser support. To get the best of both worlds, try innerWidth first, and fallback to clientWidth if not supported. Source https://vanillajstoolkit.com/reference/viewport/viewport-width/

Page Details

Get the height of the viewport

Get the height of the viewport

There are two methods to get the viewport height: window.innerHeight and document.documentElement.clientHeight. The former is more accurate. The latter has better browser support. To get the best of both worlds, try innerHeight first, and fallback to clientHeight if not supported. Source https://vanillajstoolkit.com/reference/viewport/viewport-height/

Page Details

Notify when element size is changed

Notify when element size is changed

Source https://github.com/roeib/JavaScript-snippets#notify-when-element-size-is-changed

Page Details

Check if a node is in the viewport

Check if a node is in the viewport

Source https://github.com/roeib/JavaScript-snippets#check-if-a-node-is-in-the-viewport

Page Details

Find the distance from a given element to the top of the document

Find the distance from a given element to the top of the document

Use getVerticalOffset to find the distance from a given element to the top of the document.

Page Details

Return the current URL

Return the current URL

Use Window.location.href to get the URL of the current page.

Page Details

Redirection: How to Change the URL in JavaScript

Redirection: How to Change the URL in JavaScript

We’ll go through the different built-in methods provided by JavaScript to implement URL redirection. In fact, JavaScript provides the location object, a part of the window object, which allows you to perform different URL-related operations.

Page Details

Calculate the size of scrollbar

Calculate the size of scrollbar

The clientWidth property indicates the width without scrollbar. The offsetWidth, on the other hand, includes the scrollbar if there is.

Page Details

Check If the Document is Ready

Check If the Document is Ready

To check if the document is ready and execute some code, you bind an event listener to the DOMContentLoaded event of the document object.

Page Details

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

Primary Sidebar

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2025 JavaScriptSource.com

  • About
  • Privacy Policy
  • FAQ
  • Jobs For Developers