iframe 父窗口和子窗口的調用方法 父窗口調用子窗口 iframe_name.iframe_document_object.object_attribute = attribute_value 例子:onClick="iframe_text.myH1.innerText='http://www.pint.com';" 子窗口調用父窗口parent.parent_document_object.object_attribute = attribute_value 例子:onclick="parent.myH1.innerText='http://www.pint.com';" 上面在IE下沒有問題,但在firefox下不正常。在firefox下,應該是 父窗口調用子窗口 window.frames["iframe_name"].document.getElementById("iframe_document_object"-).object_attribute = attribute_value 例子 window.frames["iframe_text"].document.getElementById("myH1").innerHTML= " 子窗口調用父窗口 parent.document.getElementById("parent_document_object").object_attribute = attribute_value 例子 parent.document.getElementById("myH1").innerHTML = " 完整例子: start.html <html> <script type="text/javascript"> function b(){ alert("父窗口編輯子窗口的內容。。。"); window.frames["floater"].document.getElementById("bb").innerHTML="父窗口改變子窗口內容"; //下句只適合IE瀏覽器 //floater.bb.innerText="父窗口修改子窗口內容。。。"; } </script> <body> <IFRAME name="floater" src="three.html" width=1000 height=600 hspace=20 vspace=20 align=right frameborder=1> </IFRAME><BR> <img src="星球大戰.jpg" /><br> <A id="aa" href="one.html" target="floater">Show one.htm</A><P> <form id="a" action="#" method="post"> <input type=button value="修改子窗口內容" onclick="b()"> </form> </body> </html> one.html <html> one.html </html> three.html <html> <script typt="text/javascript"> function a(){ alert("子窗口編輯父窗口內容parent表示父窗口"); //下句只適合IE瀏覽器 //parent.aa.innerText="ppppppppppppp"; parent.document.getElementById("aa").innerHTML="修改父窗口內容"; //parent.frames["iframe的名稱"].document.getElementById("aa").innerText="修改父窗口內容。。。。"; //子窗口修改父窗口的另一個子窗口的內容 } </script> <body onload="a()"> <h1 id="bb">改變父窗口的元素值。</h1> </body> </html>