I didn't pay much attention to this before, so I studied.
location.pathname:
Returns the part of the URL after the domain name (domain name IP). For example
http://www.joymood.cn/wordpress/return to/wordpress/, or http://127.0.0.1/index.html
Return to/index.html, Note is a domain name or domain name IP with a URL, build a random HTML file on the disk for location.pathname testing, such as the path on the browser:
C:\Documents
and settings\administrator\ Desktop \testjs.html,
In this way, the resulting result is:
/c:\documents and
Settings\administrator\ Desktop \testjs.html
Since this is mentioned, let's analyze the following URL:
Http://www.joymood.cn:8080/test.php?user=admin&pwd=admin#login
To get the complete URL as above, we use:Location.href;
Get the Transfer Protocolhttp:,We use:Location.protocol;
Get the hostname along with the portwww.joymood.cn:8080, we use:Location.host;
Get host Namewww.joymood.cn, we use:Location.hostname;
Get the host after part does not include the question mark? The latter part of the/test.php, as we have just said:Location.pathname;
Get the question mark in the URL and the part before the pound sign #? user=admin&pwd=admin, we will use:
Location.search;
Get the part before ##login, we will useLocation.hash;
As described above, we can get the parts of a full URL through some properties of the location object.
============================
JavascriptLocation.pathname in the(2012-03-15 22:24:16)
location.pathname "src=" in Location.pathname "align=" Absmiddle " alt=" javascript/HTTP// Simg.sinajs.cn/blog7style/images/common/sg_trans.gif "real_src=" http://simg.sinajs.cn/blog7style/images/common/ Sg_trans.gif "> Reprint
Tags: Javascript Pathname |
Category: Javascript |
Location.pathname:
Returns the part of the URL after the domain name (domain name IP).
For example
- http://www.joymood.cn/wordpress/return/wordpress/
- Http://127.0.0.1/index.html
Back to/index.html
Note is a domain name or domain name IP with a URL, on the disk to build a random HTML file for location.pathname testing, such as the path on the browser is: C:\Documents
and settings\administrator\ Desktop \testjs.html,
In this way, the resulting result is:/c:\documents and
Settings\administrator\ Desktop \testjs.html
Parse the following URL:
Http://www.joymood.cn:8080/test.php?user=admin&pwd=admin#login
- Location.href: Get the complete URL as above
- Location.protocol: Get the Transport protocol http:
- Location.host: Get host name together with Port http://www.joymood.cn:8080/
- Location.hostname: Get host name http://www.joymood.cn/
- Location.pathname: Get the host after part does not include the question mark? The latter part of the/test.php
- Location.search: Get the question mark in the URL, then the part before the pound #? user=admin&pwd=admin
- Location.hash: Get the part before # #login
The Location.pathname in JavaScript