日期:2014-05-17  浏览次数:20754 次

html 页面之间传递参数----js

aa.html========

<html>

<head>

</head>

<body>

<script>

function submit()

{

var input1 = document.getElementById("inputid");

window.open("C:/Users/lenovo/Desktop/test/bb.html?inputStr=" + input1.value);//传入参数

}

</script>

<input type = "text" id = "inputid">

<input type = "button" onclick = "submit()" value = "提交">

</body>

</html>

?

bb.html========

<html>

<head>

<script>

//获得参数的方法

var request = {?

QueryString : function(val) {?

var uri = window.location.search;?

var re = new RegExp("" +val+ "=([^&?]*)", "ig");?

return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);?

}?

}

</script>

</head>

<body>

<script>

//调用方法获得参数

var rt = request.QueryString("inputStr");

alert(rt);

</script>

</body>

</html>