我試圖從父窗口傳遞一些數據以在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