1.document.location.href 返回完整的 URL。 如:http://www.cftea.com/foo.asp?p=1
引用
location.search是從當(dāng)前URL的?號(hào)開(kāi)始的字符串
如:http://www.51js.com/viewthread.php?tid=22720
它的search就是?tid=22720
通過(guò)這個(gè)函數(shù)就可以輕易取到連接后面帶的參數(shù),這個(gè)可用戶(hù)父窗口向子窗口傳遞參數(shù)
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頁(yè)面中如果我們要獲取id的值的話(huà),可以這樣獲得
<script type="text/javascript">
var params= window.location.search;//params:?id,date
var arr = params.substring(1).split(",");
var id = arr[0];
</script>
2.document.location.search 返回 URL 中的 QueryString 部分,含“?”。 如:?p=1