location.href 与 location.search

1.document.location.href 返回完整的 URL。 如:http://www.cftea.com/foo.asp?p=1

引用


location.search是从当前URL的?号开始的字符串 
如:http://www.51js.com/viewthread.php?tid=22720 
它的search就是?tid=22720 


通过这个函数就可以轻易取到连接后面带的参数,这个可用户父窗口向子窗口传递参数 
eg: 

function openTable(id){   
var feathers="status=no,width=650px,height=670px,top=0px,menubar=no,resizable=no,scrollbars=yes,toolbar=no,channelmode=no";   
var openWin = window.open("allInfo.html?"+id+","+new Date().getTime(),"declare",feathers);   
openWin.focus();   
}  

在allInfo.html页面中如果我们要获取id的值的话,可以这样获得 

<script type="text/javascript">   
    var params= window.location.search;//params:?id,date   
       
    var arr = params.substring(1).split(",");   
       
    var id = arr[0];   
</script>  

 

转载于:https://my.oschina.net/joldy/blog/823743

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值