Current URL

JavaScript, Browser · Oct 20, 2020

Returns the current URL.

  • Use Window.location.href to get the current URL.
const currentURL = () => window.location.href;
currentURL(); // 'https://www.google.com/'

More like this

  • URLs in JavaScript

    Working with URLs is an essential skill for web developers. This snippet collection covers all the necessary resources to master URLs in JavaScript.

    Collection · 12 snippets

  • URL parameters as object

    Creates an object containing the parameters of the current URL.

    JavaScript, Browser · Oct 22, 2020

  • Prefix CSS property

    Prefixes a CSS property based on the current browser.

    JavaScript, Browser · Oct 22, 2020

  • HTTP post

    Makes a POST request to the passed URL.

    JavaScript, Browser · Oct 19, 2020