<div align=left id=App style="background-color:#F7F7F7;height:380px;overflow:auto;width:100%;z-index:2" contentEditable></div>
<iframe contentEditable></iframe>

解决方案 »

  1.   

    将文档设置为设计模式 要将整个文档设置为设计模式,可以对文档对象本身设置 designMode 属性。当文档处于设计模式时,将不运行脚本。这样,似乎在文档内设置一个按钮来打开或关闭设计模式是个好注意,但这样做没有作用。当用户打开它后,它将保持在设计模式状态。当他们下次单击此按钮时,它将被选定而不是被单击,他们再次单击它,将能够编辑它的值。这就是为什么如果要使用设计模式最好对框架或 IFrame 中的文档设置 designMode 属性的原因。下例展示如何为 IFrame 中的文档打开设计模式:<script for="btnDesign" event="onclick">
      targetDoc = document.frames(0).document;
      if (targetDoc.designMode == "On")
        targetDoc.designMode = "Off";
      else
        targetDoc.designMode = "On";
    </script>
    <button id=btnDesign>DesignMode</button>
    <iframe src="blank.htm" style="border: black thin; width:100%; height:200px"></iframe>
      

  2.   

    IFrame也可以编辑文字 有没有想过除了表单(<form>)之外还有其它的网页元素可以编辑文字呢?只要使用IFrame的隐藏的一个属性就可以使IFrame成为一个文本编辑器。 
    <html> 
    <body onload="editer.document.designMode='On'"> 
    <IFrame ID="editer"></IFrame> 
    </body> 
    </html> 
    其中designMode属性表示IFrame的设计模式的状态(开/关),还在犹豫什么呢,快试试吧! 
    只要巧妙的利用这一特性就可以制作很多意想不到的效果。如果下面我们来做一个图片编辑器。 
    <html> 
    <body onload="imgEditer.document.designMode='On';imgEditer.document.write('<img src=图片.gif>')"> 
    <IFrame id="imgEditer"></IFrame> 
    </body> 
    </html> 
    用鼠标点击图片是不是有新的发现,其实大家只要利用自己的想象和充分利用这个属性一定能做出更多的花样来,别忘了到时候有什么新的东东,告诉我一声呀!(Email:[email protected]
      

  3.   

    <!--顶楼是一段完整的代码,大家帮我测试一下-->
    想在iframe里显示纯文本,就像在textarea里一模一样,帮帮我!
    1.希望注释也能显示出来
    2.希望换行能显示出来
      

  4.   

    http://www.silver-henry.com/snowkiss/jswz/html/execcmd.htm
    看看这个htm的源代码,挺nb的
      

  5.   

    Editor.document.write ("<!--请选中这些文字,并点上面的链接看看效果!!!-->用的iframe,挺牛的,但还不理想,注释中的文字没了!");
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>ubb编辑器</title>
    <link href="../../css/snowkiss.css" rel="stylesheet" type="text/css">
    </head> 
    <body>
    <div align="center">
    <table width="450" height="100" cellpadding="4" cellspacing="0">
    <tr align="center"> 
    <td width="80" style="border:dotted 1px"><a href="#" onClick="execCmd('SelectAll')">SelectAll</a></td>
    <td width="80" style="border:dotted 1px"><a href="#" onClick="execCmd('bold')">Bold</a></td>
    <td width="80" style="border:dotted 1px"><a href="#" onClick="execCmd('Italic')">Italic</a></td>
    <td width="80" style="border:dotted 1px"><a href="#" onClick="execCmd('underline')">Underline</a></td>
    <td width="80" style="border:dotted 1px"><a href="#" onClick="execCmd('cut')">Cut</a></td>
    <td width="80" style="border:dotted 1px"><a href="#" onClick="execCmd('Paste')">Paste</a></td>
    </tr>
    <tr> 
    <td colspan="6" style="border:dotted 1px"><iframe align="middle" width="100%" height="100%" marginheight="0" marginwidth="0" frameborder="0" id="Editor"></iframe></td>
    </tr>
    </table>
    </div>
    </body>
    </html>
    <script language="JavaScript">
    //初始化编辑器
    Editor.document.designMode="On";
    Editor.document.open ;
    Editor.document.write ("<!--请选中这些文字,并点上面的链接看看效果!!!-->用的iframe,挺牛的,但还不理想,注释中的文字没了!");
    Editor.document.close ;
    Editor.focus();
    //初始化结束
    function execCmd(CmdIdentifiers)
    {
    Editor.document.execCommand(CmdIdentifiers);
    return(true);
    }
    </script>