Techstacker
Light ModeDark ModeReset dark mode. Falls back to OS dark mode setting.

Pages

No results for 'undefined'

Blog Posts

No results for 'undefined'
Powered by Algolia

How to Get the current Page URL with JavaScript

Jan 7, 20181 min readJavaScript, TutorialViews:

To get the current web page URL of your browser you need to grab the window.location.href property.

Type the following code in your browser console and hit enter:


var currentURL = window.location.href;

currentURL();
Gif video. Getting the window URL via the Chrome Console
If you’re using an online editor like CodePen, you need to use console.log(currentURL) to return the result.

Has this been helpful?
Let me know in the comments!

Or share it with your friends :-)


© 2019 - TechStacker
Powered byGatsbyGithubNetlify