1

このコードを使用して、親ウィンドウフォームポップアップの要素に文字列を追加します。

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>
4

2 に答える 2

2

このコードを使用します:

window.opener.document.getElementById('iframeelementid').innerHTML +=  'string';
于 2012-11-20T10:06:26.783 に答える
1

使用できますwindow.opener

ここを見てください

window.opener.document.getElementById('ID').innerHTML +=  'Yor STR';
于 2013-02-05T09:55:19.293 に答える