Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current URL using javascript [duplicate]

I have a current URL:

http://www.test.com/p1234?utm_source=....

How do I get a URL with the format http://www.test.php/p1234

I am using javascript document.URL, the result is http://www.test.com/p1234?utm_source=....

like image 545
linh.gust Avatar asked Feb 21 '26 13:02

linh.gust


1 Answers

This is the correct answer:

window.location.host + window.location.pathname;
like image 105
ebertx Avatar answered Feb 23 '26 02:02

ebertx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!