What is "window.location.origin" in JavaScript?
822

window.location.origin is a read-only property in JavaScript that returns the origin of the current page. The origin is a combination of the protocol, hostname, and port number (if specified) of the URL.

For example, if the current page's URL is "https://www.example.com/some/path/page", then window.location.origin will return "https://www.example.com".

It is worth noting that window.location.origin is supported in modern browsers, including all major browsers like Chrome, Firefox, Safari, and Edge, but it may not be available in some older versions of Internet Explorer.

This property is particularly useful when you need to construct URLs relative to the current page's origin, as it provides a convenient way to access this information without manually parsing and concatenating the various parts of the URL.

If you are looking for consultation, fill the Contact Form below.
The future is in the skies. Mustafa Kemal ATATURK
Haluk YAMANER - Personal
Contact Form
You must complete Security Verification to submit your form.