推 midio:辛苦了你>"< 謝謝~ 06/21 18:50
※ 引述《midio (why..)》之銘言:
: 在frame1.html的script中加入
: parent.document.getElementByID('ifram2').contentWindow.refresh1()
: 或self.arent.document.getElementByID('ifram2').contentWindow.refresh1()
: 在IE6.0
: 是可以work(呼叫成功)
: 但firefox2.0.0.4
: 說parent.document.getElementByID('ifram2') has no properties
: 懇請賜教<囧>謝謝><
很認真試了一下,
iframe1.html:
<script>
function test() {
alert('test in iframe1.html');
}
</script>
iframe2.html:
<script>
var doc = parent.document.getElementById('iframe1').contentDocument;
alert(doc.getElementsByTagName('SCRIPT')[0].childNodes[0].nodeValue);
</script>
frame.html
<iframe id="iframe1"></iframe>
<iframe id="iframe2"></iframe>
執行frame.html會印出iframe1.html中 'function test() ...' 等函數內容.
也許可先把這文字加入iframe2.html的<SCRIPT>集合,建立為一個新node,
然後做一點字串處理,把子字串 'test()' 剖析出來,且eval它.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.112.226.241