Window.location method Get URL
Uniform Resource Locator (Uniform Resource Locator, URL)
The complete URL consists of the following parts:
Scheme://host:port/path?query#fragment
Scheme: Common Http,ftp,maito of communication protocols, etc.
Host server (computer) domain Name System (DNS) hostname or IP address.
Port: The port number is an integer, optional, omitted when using the default port of the scenario, such as HTTP with the default port of 80.
Path: A string separated by 0 or more "/" symbols, typically used to represent a directory or file address on a host.
Query: Queries are optional for use with dynamic Web pages such as CGI, ISAPI, php/jsp/asp/asp. NET and other technical Web pages) pass parameters, can have multiple parameters, separated by the "&" symbol, the name and value of each parameter is separated by the "=" symbol.
Fragment: A message fragment string that specifies a fragment in a network resource. For example, there are multiple noun interpretations in a Web page, and you can use fragment to navigate directly to a noun interpretation. (also known as anchor points.)
Example:
Http://www.home.com:8080/windows/location/page.html?ver=1.0&id=timlq#love
1, window.location.href the entire URL string (in the browser is the full address bar)
return value: Http://www.home.com:8080/windows/location/page.html?ver=1.0&id=timlq#love
The protocol portion of the 2,window.location.protocol URL
Return value: http:
3,window.location.host the host part of the URL
return value: www.home.com
4.window.location.hostname
return value: www.home.com:8080
The port portion of the 5,window.location.port URL. If you are using the default 80 port (update: Even if you added: 80), the return value is not the default of 80 but the null character.
This example returns the value: 8080
The path portion of the 6,window.location.pathname URL (that is, the file address)
return value:/windows/location/page.html
7,window.location.search the query (parameters) section. In addition to assigning values to dynamic languages, we can also give static pages and use JavaScript to get the values of the arguments we believe in.
Return value:? ver=1.0&id=timlq
7,window.location.hash Anchor Point
return value: #love
Original blogger: http://blog.csdn.net/csdn_girl/article/details/55095805
Window.location the meaning of each attribute