1,点击index.html中的按钮 在frqme_a.htm文档中ID=BOX1后面添加一个DIV标签,ID=BOX1前面添加一个DIV标签
2,如何获取当前窗口中id=frame_a 框架中的所有文档3,问题还有很多!先解决这两个
index.html<html>
<herd>
<script type="text/javascript">
<!--
        function to_f_a() {
           这里怎么写
        }
//-->
</script>
</herd><body><frame src="frame_a.htm" id="frame_a"><input type="button" value="添加DIV" onclick="to_f_a()" /></body>
</html>frame_a.htm<html>
<body><div id="box1"></div></body>
</html>

解决方案 »

  1.   


    <html> 
    <head> 
    <script type="text/javascript"> 
    <!-- 
    function to_f_a() { 
       var doc = document.getElementById("frame_a").contentWindow.document;
       var div = doc.createElement("div");
       div.innerHTML = "inner";
       var box = doc.getElementById("box1");
       box.appendChild(div);
       var div1 = doc.createElement("div");
       div1.innerHTML = "outer";
       box.parentNode.insertBefore(div1,box);

    //--> 
    </script> 
    </head> <body>
    <iframe src="frame_a.htm" id="frame_a"></iframe>
    <input type="button" value="添加DIV" onclick="to_f_a()" />
    </body> 
    </html> 
      

  2.   

    当前窗口中id=frame_a 框架中的所有文档 是什么意思?
    document.getElementById("frame_a").contentWindow.document.body.innerHTML
      

  3.   

    因为在<iframe src="frame_a.htm" id="frame_a"></iframe>
    窗体内建了DIV 我想保存当前窗体内所有内容保存包括<html></html>
      

  4.   


       if(document.all) alert(document.getElementById("frame_a").contentWindow.document.body.parentNode.outerHTML)
       else alert("<html>" + document.getElementById("frame_a").contentWindow.document.body.parentNode.innerHTML + "</html>")
      

  5.   

    就是这里了!只是能读到<body>中的内容吗</body>
      

  6.   

    document.body.parentNode可读到html里的