JavaScript弹出新窗口后向父窗口输出内容的方法
本文实例讲述了JavaScript弹出新窗口后向父窗口输出内容的方法。分享给大家供大家参考。具体如下:
下面的JS代码演示了如何通过window.open方法打开一个弹出窗口,然后通过弹出窗口的句柄向父窗口输出信息的方法
<!DOCTYPEhtml>
<html>
<head>
<script>
functionopenWin()
{
myWindow=window.open('','','width=200,height=100');
myWindow.document.write("<p>Thisis'myWindow'</p>");
myWindow.focus();
myWindow.opener.document.write("<p>Thisisthesourcewindow!</p>");
}
</script>
</head>
<body>
<inputtype="button"value="Open'myWindow'"onclick="openWin()"/>
</body>
</html>
希望本文所述对大家的javascript程序设计有所帮助。