利用js方法实现html静态页面间参数传递

利用js方法实现html静态页面间参数传递 

aa.htm是参数输入界面
bb.htm是参数接收处理界面
aa.htm
<html>
<head>
</head>
<body>
<script>
function submit()
{
var input1 = document.getElementById("inputid");
window.open("b.html?inputStr=" + input1.value);//传入参数
}
</script>
<input type = "text" id = "inputid">
<input type = "button" onclick = "submit()" value = "提交">
</body>
</html>

bb.htm:
<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>

你可以通过这个链接引用该篇文章:http://ranjunliu.bokee.com/viewdiary.13398085.html

posted on 2008-05-13 11:23  Harlan---  阅读(3977)  评论(1编辑  收藏  举报

导航