If you're looking to manipulate URLs, one useful tool you can utilize is the JavaScript Window Location.
The window.location
object allows you to access the current page's address or URL.
This object has various properties and methods, some of which include:
window.location.href
- returns the URL of the current page
window.location.hostname
- returns the domain name of the web host
window.location.pathname
- returns the path and filename of the current page
window.location.protocol
- returns the web protocol used (http: or https:)
window.location.assign()
- loads a new document
For example:
To display the current page's URL:
<script>
alert(window.location.href);
</script>
For more information on JavaScript Window Location, visit: Window Location