ie6下不可以  
不知道如何修改!~
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<head>
<script>
var ed = null;
var cd = null;
window.onload = function() {
    var o = document.getElementById("ss"); 
    ed = document.all?o.contentWindow.document:o.contentDocument;
    ed.open();
    ed.write('<html><head><style>body{margin:5px;font:14px;word-wrap:break-word}</style></head><body id="my_body">232</body></html>');
    ed.close();
    ed.contentEditable = true;
    ed.designMode = 'on';
//////////////////////////////////////////////////////};function ss(){
alert(ed.body.innerHTML)
    ed.body.appendChild(document.createElement("hr")) 
}
</script>
</head>
<BODY>
<IFRAME id="ss" height="200" src="about:blank" width="200" ></IFRAME>
<input value="add" type="button" onclick="ss()" />
<hr>
</BODY></HTML>

解决方案 »

  1.   

    function ss(){
       alert(ed.body.innerHTML)
        ed.body.appendChild(ed.createElement("hr")) }
      

  2.   


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <HTML>
    <head>
    <script>
    var ed = null;
    var cd = null;
    window.onload = function() {
        var o = document.getElementById("ss"); 
        ed = document.all?o.contentWindow.document:o.contentDocument;
        ed.open();
        ed.write('<html><head><style>body{margin:5px;font:14px;word-wrap:break-word}</style></head><body id="my_body">232</body></html>');
        ed.close();
        ed.contentEditable = true;
        ed.designMode = 'on';
    //////////////////////////////////////////////////////};function ss(){
        alert(ed.body.innerHTML)
        
        ed.body.appendChild(ed.createElement("hr")) 
    }
    </script>
    </head>
    <BODY>
    <IFRAME id="ss" height="200" src="about:blank" width="200" ></IFRAME>
    <input value="add" type="button" onclick="ss()" />
    <hr>
    </BODY></HTML>