第一个页面 page1.html
<html>
<head>
<title>Page 1</title>
<script type="text/javascript">
function topage2()
{
var parm1=document.getElementById("tx1").value;
var parm2=document.getElementById("tx2").value;
var myurl="page2.html"+"?"+"parm1="+parm1+"&parm2="+parm2;
window.location.assign(encodeURI(myurl));
}
</script>
</head>
<body>
<label id="label1" >page1</label>
<br><br>
<input type="text" id="tx1" value="text 1">
<input type="text" id="tx2" value="text 2">
<input type="button" id="bt2" value="go to page2" onclick="topage2()">
</body>
</html>
第二个页面 page2.html
<html>
<head>
<title>Page 2</title>
<script type="text/javascript">
function getparam1()
{
var url=location.href;
var tmp1=url.split("?")[1];
var tmp2=tmp1.split("&")[0];
var tmp3=tmp2.split("=")[1];
var param1=tmp3;
alert(decodeURI(param1));
}
function getparam2()
{
var url=location.href;
var tmp1=url.split("?")[1];
var tmp2=tmp1.split("&")[1];
var tmp3=tmp2.split("=")[1];
var param2=tmp3;
alert(decodeURI(param2));
}
</script>
</head>
<body>
<label id="label1" >page2</label>
<br><br>
<input type="button" id="bt1" value="get parm1" onclick="getparam1()">
<br><br>
<input type="button" id="bt2" value="get parm2" onclick="getparam2()">
</body>
</html>
结果查看:
用浏览器打开page1.html

点击go to page2按纽,进入page2.html

713

被折叠的 条评论
为什么被折叠?



