How To Get URL Parts in JavaScript
Posted: Wed, Mar 23 05:27 AM (PDT)The window.location object is a JavaScript class that is used to store URLs. It comes with properties that represent each part of the URL, and can be updated by changing the href property. The key properties that this article deals with are:
- window.location.href - the full URL address
- window.location.protocol - the protocol what you use http or https
- window.location.host - the hostname (for example localhost or www.atlas365.com or different)
- window.location.pathname - the parts of the URL (for example index.html)
In addition there are various methods that:
- window.location.reload() - the function for reload current webpage
- window.location.replace(url) - the function for change URL address // for example window.location.replace("http://www.atlas365.com");
