- window.location.href (set or get the entire URL as a string)
var url = window.location.href;
alert(url);
- window.location.protocol (set or get the protocol part of the URL)
var url = window.location.protocol;
alert(url);
- window.location.host (set or get the host part of the URL)
var url = window.location.host;
alert(url);
- window.location.port (set or get the port number associated with the URL)
var url = window.location.port;
alert(url);
- window.location.pathname (set or get with the path part of the URL)
var url = window.location.pathname;
alert(url);
- window.location.search (sets or gets the part of the href attribute that follows the question mark)
ar url = window.location.search
alert(url)
//返回:?userName=hyman&age=24
- window.location.hash (sets or gets the segment after the pound sign "#" in the href attribute)
var url = window.location.hash;
alert(url);