JavaScript Basics

JavaScript Advanced

JavaScript Arrays

JavaScript Functions

JavaScript Objects

JavaScript DOM

JavaScript String

How to get the current URL in JavaScript?

If you want to get the current URL, then call href property of the Location object. The URL returns by location.href property includes the following:

  • Protocol
  • Hostname or domain name
  • Port number
  • Query string parameters
  • Fragment identifier
let url = location.href;

url = window.location.href;

Recommended Posts