window.location 对象

http://www.home.com:8080/windows/location/page.html?ver=1.0&id=timlq#love  javascript

1, window.location.href  整个URl字符串(在浏览器中就是完整的地址栏)  返回值:http://www.home.com:8080/windows/location/page.html?ver=1.0&id=timlq#love   2,window.location.protocol  URL 的协议部分  返回值:http:  html

3,window.location.host  URL 的主机部分(带端口号)java

  返回值:www.home.com:8080windows

          window.location.hostname浏览器

        返回值:www.home.comspa

4,window.location.port  URL 的端口部分。若是采用默认的80端口(update:即便添加了:80),那么返回值并非默认的80而是空字符。  本例返回值:8080   5,window.location.pathname  URL 的路径部分(就是文件地址)  返回值:/windows/location/page.html  htm

6,window.location.search  查询(参数)部分。除了给动态语言赋值之外,咱们一样能够给静态页面,并使用javascript来得到相信应的参数值  返回值:?ver=1.0&id=timlq   7,window.location.hash  锚点  返回值:#loveip

相关文章
相关标签/搜索