a.html
Documenttitle>
輸入:
body>
$(":button").click(function(){
var val=$("#in").val();
window.open("b.html?id="+val) //location.href="b.html?id=" target="_blank" rel="external nofollow" +val
// var str="as=df"
// alert(str.indexOf("="))
// str=str.substr(2)
// alert(str)
})script>html>
b.html
Documenttitle>head>
bbbbbbbbody>
var href1=location.search;
alert(href1) var len=href1.indexOf("=")+1
alert(len) script>html>
結果:?id=22
總結:主要是location.search這個函數,得到參數部分,然後可以用字元串截取的方法得到參數。