3

我有一个当前网址:

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

如何获取格式为 URLhttp://www.test.php/p1234

我正在使用 javascript document.URL,结果是http://www.test.com/p1234?utm_source=....

4

2 回答 2

2

这是正确的答案:

window.location.host + window.location.pathname;
于 2013-10-03T04:39:41.177 回答
0

你要这个:

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

查看文档:https ://developer.mozilla.org/en-US/docs/Web/API/Location

于 2013-10-03T04:33:59.603 回答