我们用具体的例子来实现这个功能。
a.html
<html>
<head>
<script type="text/javascript">
function aa()
{
window.location=("b.html?t='hello'");
}
</script>
</head>
<body>
<input type="button" value="click" οnclick="aa();" />
</body>
</html>
b.html
<html>
<head>
<script type="text/javascript">
function mygetstr()
{
var myhref,pos,showtext;
myhref=window.location.href;
pos=myhref.indexOf("=");
showtext=myhref.substring(pos+1);
document.getElementById("mytext").value=showtext;
}
</script>
</head>
<body οnlοad="mygetstr();">
<input type="text" id="mytext" />
</body>
</html>
直接存为两个.html文件就行了。这里演示的只是传递一个参数的方法,其他情况请读者举一反三。另外在页面传值的情况中,很少是在静态页面的,都是在网站中,或者说是在后台代码中实现的,所以读者对于这篇文章只做参考就行了,不用深入研究。