日期:2014-05-16  浏览次数:20341 次

各位大狭:请问怎么在实现关闭窗口的时候传递参数给另外一个窗口?
我想在关闭当前窗口的同时,打开另外一个窗口并传递一个参数过去,怎么实现啊?

------解决方案--------------------

<body onbeforeunload= "...aspx?paras=12333333 ";>

------解决方案--------------------

<html>
<head>
<title> PostDataToOtherPage </title>
<script>
function postdata(mydata)
{
window.open( "OtherPage.htm? " + encodeURI(mydata));//把数据编码后,弹出新页面,把数据传递过去
//window.open( "OtherPage.asp?mydata= " + encodeURI(mydata));//如果是传递到asp或php等页面,得到传递过来的数据就太容易了。我就不详述了。
}
</script>
</head>

<body onunload= "postdata( 'Are you OK? '); ">
请关闭页面!
</body>
</html>

如果是传递到静态页面,用decodeURI(location.search.substr(1))得到传递过来的参数并解码:

<html>
<head>
<title> 接受提交演示 </title>
</head>

<body>

<SCRIPT lanaguage= "javascript ">
var mydata = decodeURI(location.search.substr(1));
document.write(mydata);
</SCRIPT>
</body>
</html>