location对象

  window的一个对象

  如果浏览的页面地址为

  http://www.web.com/index.aspx?id=1#somename

  那么

  location.href的为

http://www.web.com/index.aspx?id=1#somename

 location.hash的值为somename

 location.host的值为www.web.com

 location.protocol的值为http

 location.port的值为空 因为默认是 80端口 但是即使设置成80端口也会取不到其他端口可以

 location.pathname的值为/index.asp

 location.search的值为?id=1

 location.hash的相关应用

 有个地方就是ajax方面我没有试验过

 在网上看到一个文章

 由于没实践 先放这吧


var hash;
hash
=(!window.location.hash)?"#search":window.location.hash;
window.location.hash
=hash;
   
//调整地址栏地址,使前进、后退按钮能使用
switch(hash){  
case "#search":
     selectPanel(
"pnlSearch");    //显示普通搜索面板
     break;   
case "#advsearch":   
      
case "#admin":
     
}
posted @ 2008-07-27 03:35  fool  阅读(156)  评论(0编辑  收藏  举报