javascript 子窗口读取父窗口数据
时间:2009-07-03 来源:emanbox
在javascript里,使用window.open()方法可以打开另一个窗口,
可是在这个新打开的窗口里如何可以获得父窗口中的数据呢?
我们可以使用这样一个方法:
window.opener.document....
这句话的意思是得到父窗口的document对象
能够得到父窗口的document对象,这事就好办多了。
我们写这么一段程序
<!-- 父页面 -->
<html>
<body>
<input type="text" id='tt'>
<button onclick="window.open('dd.html');">open</button> <!-- 打开一个子窗口 -->
</body>
</html>
<!-- 子页面 -->
<html>
<body>
<button onclick="dd()">open</button>
</body>
</html>
可是在这个新打开的窗口里如何可以获得父窗口中的数据呢?
我们可以使用这样一个方法:
window.opener.document....
这句话的意思是得到父窗口的document对象
能够得到父窗口的document对象,这事就好办多了。
我们写这么一段程序
<!-- 父页面 -->
<html>
<body>
<input type="text" id='tt'>
<button onclick="window.open('dd.html');">open</button> <!-- 打开一个子窗口 -->
</body>
</html>
<!-- 子页面 -->
<html>
<body>
<button onclick="dd()">open</button>
</body>
</html>
相关阅读 更多 +