我试图从父窗口传递一些数据以在HTML中弹出窗口。如何将数据从父窗口传递到弹出窗口
下面是我的代码 -
<html>
<head>
<script type="text/javascript">
function init()
{
popupWin = window.open('','popupWin','');
popupWin.document.writeln('<html><head><title>test</title></head><body><form><input type="text" id="popupTextBox"/></form></body></html>');
popupWin.document.close();
popupText = popupWin.document.getElementById("popupTextBox");
parentText = document.getElementById("parentTextBox");
}
function transferText()
{
popupText.value = parentText.value
}
</script>
</head>
<body>
<input type="text" id="parentTextBox"/>
<input type="button" onclick="init();"/>
</body>
</html>
但不知何故,我不能来传递文本数据与上面的代码来弹出窗口。这有什么问题吗?
一般来说,我试图将一些数据从父窗口传递到弹出窗口。
这可能有助于http://stackoverflow.com/questions/5187510/how-can-a-javascript- parent-window-send-data-to-popup-window – Seano666