29 points

Get URL and URL Parts in JavaScript


dashboard

Fri May 01 2020 11:13:14 GMT+0000 (UTC)

Posted by @FlowerFine #javascript

var newURL = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname + window.location.search
                                
content_copy Copy

The above code is used to get URL and also Parts of URL in JavaScript

https://css-tricks.com/snippets/javascript/get-url-and-url-parts-in-javascript/