请问:当把iframe变成编辑器时,想调看iframe上面的东西,那句怎么写? 谢谢!<iframe id=write></iframe>
<input type=submit onclick=ok() value=sub ><script>
editor=document.getElementById("write");                    
editor=editor.contentWindow.document;
editor.designMode = "on";
function ok(){
alert(editor上面的内容);  //这句怎么写?
}
</script>

解决方案 »

  1.   

    内层页面
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
    </head>
    <body>
        <textarea id="TextArea1" cols="20" rows="2"></textarea>
    </body>
    </html>
    外层页面
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title>无标题页</title>
        <script type="text/javascript">
            function getiframe(){
                var tiframe=document.getElementById("tiframe");
                alert(tiframe.contentDocument.getElementById("TextArea1").value);
                alert(tiframe.contentDocument.body.innerHTML);
            }
        </script>
    </head>
    <body>
        <table>
            <tr>
                <td><iframe id="tiframe" src="test.htm" width="400" height="300" frameborder="1" scrolling="auto"></iframe></td>
            </tr>
            <tr>
                <td><input id="Button1" type="button" value="button" onclick="getiframe();" /></td>
            </tr>
        </table>
    </body>
    </html>
      

  2.   

    不要只顾up,不知道有没有测试过呢?我给出的代码是自己测试过的,在FF中没有问题。