JavaScript Location Object js 对 URL 的解析

统一资源定位符 (Uniform Resource Locator, URL) 完整的URL由这几个部分构成:

scheme://host:port/path?query#fragment

document.write("location.host="+location.host+"<br>");
document.write("location.hostname="+location.hostname+"<br>");
document.write("location.href="+location.href+"<br>");
document.write("location.pathname="+location.pathname+"<br>");
document.write("location.search="+location.search+"<br>");
document.write("location.protocol="+location.protocol+"<br>");

 

location.host=www.cowboystudio.net
location.hostname=www.cowboystudio.net
location.href=http://www.cowboystudio.net/index.php?p=59
location.pathname=/index.php
location.search=?p=59
location.protocol=http:

 

location.search 可以利用 jquery.query

posted @ 2010-05-27 11:38  liuwei0514  Views(303)  Comments(0)    收藏  举报