2014-02-10 187 views

回答

30

您有:

window.location.href 

也:

document.URL 
5

如果你想返回整个URL,你需要使用window.location.href

使用window.location.pathname仅返回其排除查询参数和片段的URL(即,起始于/以下的主机但仅达到一?#)的路径部分。

实施例:

> window.location.pathname 
"/ebook" 
> window.location.href 
"http://example.com/ebook?page=43" 

此外,请参阅更多可用的属性为window.location的文档。

相关问题