2

親ウィンドウから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>

しかし、どういうわけか、上記のコードでそのテキストボックスのデータをポップアップウィンドウに渡すことができません。これに問題はありますか?

一般に、親ウィンドウからポップアップ ウィンドウにデータを渡そうとしています。

4

1 に答える 1

3

transferText()
電話するのを忘れtransferText()

<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");
    transferText();
}
function transferText()
{
    popupText.value = parentText.value
}
</script>
</head>
<body>
<input type="text" id="parentTextBox"/>
<input type="button" onclick="init();"/>
</body>
</html>
于 2013-07-09T22:14:52.653 に答える