今天做东西用到,在网上查到了这样的一种方法,学习学习:
来源:http://bbs.youkuaiyun.com/topics/310229114
Page1:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>无标题页</title> <script type="text/javascript"> function OpenWin() { window.open("father.htm","aa","",""); } </script> </head> <body> <input id="T1" type="text" /> <input id="Button1" type="button" value="提交" onclick="OpenWin();" /> </body> </html>
Page2:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>无标题页</title> <script type="text/javascript"> function ReturnVal() { window.opener.document.getElementById('T1').value=document.getElementById('Text1').value; window.close(); } </script> </head> <body> <input id="Text1" type="text" /> <input id="Button1" type="button" value="关闭" onclick="ReturnVal();" /> </body> </html>
PS:
使用window.opener可以访问js的变量 :window.opener.变量名
-------------
本文介绍了如何使用JavaScript实现简单的页面交互功能,包括创建输入框并触发页面跳转,以及在关闭页面时将输入值返回给打开页面的功能。通过实例演示了如何利用window.opener属性在不同页面间传递数据。
104

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



