kristain

博客园 首页 新随笔 联系 订阅 管理

location.search是从当前URL的?号开始的字符串 
如:http://www.51js.com/viewthread.php?tid=22720 
它的search就是?tid=22720 
通过这个函数就可以轻易取到连接后面带的参数,这个可用户父窗口向子窗口传递参数

如果地址里没有“?”,则返回空字符串。

var  url=document.location.search;   

if(url.indexOf("?")!=-1)   {   
  var   str   =   url.substr(1)     
}

posted on 2012-02-28 22:03  kristain  阅读(326)  评论(0编辑  收藏  举报