4

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=....

0

2 Answers 2

2

This is the correct answer:

window.location.host + window.location.pathname;
Sign up to request clarification or add additional context in comments.

1 Comment

also prefix the protocol used. window.location.protocal + "//" window.location.host + window.location.pathname;
0

You want this:

var location = window.location.host + window.location.pathname;

see the docs: https://developer.mozilla.org/en-US/docs/Web/API/Location

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.