2018-02-19T08:20:11Z||2018-02-19T08:20:11Z


比如这样一个URL:

https://www.google.com/search?{google:acceptedSuggestion}oq=window+location+relative&sourceid=chrome&ie=UTF-8&q=window+location+relative

然后运行

JSON.stringify(location)

得到如下有用的属性:

{  
   "href":"https://www.google.com/search?{google:acceptedSuggestion}oq=window+location+relative&sourceid=chrome&ie=UTF-8&q=window+location+relative",
   "ancestorOrigins": {
   },
   "origin":"https://www.google.com",
   "protocol":"https:",
   "host":"www.google.com",
   "hostname":"www.google.com",
   "port":"",
   "pathname":"/search",
   "search":"?{google:acceptedSuggestion}oq=window+location+relative&sourceid=chrome&ie=UTF-8&q=window+location+relative",
   "hash":""
}

相对路径对应的是:pathname属性。