このコードを使用して、親ウィンドウフォームポップアップの要素に文字列を追加します。
window.opener.document.getElementById('myid').innerHTML += 'string';
次に、iframeフォームポップアップの要素に文字列を追加します。iframeと親の両方が同じドメインにあります。私はこのコードを試しましたが、機能しません:
parent.myframename.window.opener.document.getElementById('iframeelementid').innerHTML += 'string';
なにが問題ですか?これを行う方法はありますか?
助けてくれてありがとう。
*更新*
これは私の完全なコードです。メインページ:
<html>
<head>
<script>
function myPopup() {
window.open( "pop.htm", "myWindow", "status = 1, height = 180px, width = 330px)
}
</script>
</head>
<body>
<textarea id="input"><iframe src="frame.html" name="myframe"></iframe> </textarea>
<a href="" onclick="myPopup()">Popup</a>
</body>
</html>
およびpop.htm:
<html>
<head>
<script>
function insert() {
parent.myframe.window.opener.document.getElementById('inframe').innerHTML += 'asasasas';
window.close();
return false;
}
</script>
</head>
<body>
<input type="button" id="insert" onclick="insert()" value="insert" />
</body>
</html>
およびiframe.html:
<html>
<head>
</head>
<body>
<span id="inframe"></span>
</body>
</html>