innerHTML会改变原有的字符串,令它成为标准的HTML代码.
所以可能会帮你添东西进去也可能把某些东西忽略。

解决方案 »

  1.   

    用UltraEdit看看清楚,它从哪里开始截断的,在那个位置上有什么字符。16进制编码是多少。要不然把代码贴出来一起研究。
      

  2.   

    chenzengxi(懒猫):那用什么方法解决emu(ston):
    <html>
    ...
    <body>和</body>
    </html>
    部分被删除了
      

  3.   

    如果是html(xml)标记的话,浏览器会试图对标记进行解析,你最终得到的解析后的代码也可能和原来的内容不一致。看看这个:
    <html>
    <body><iframe id=test>
    </iframe>
    <BR>
    <button onclick="testIframe()">test</button>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function testIframe()
    {
    test.document.body.innerHTML = "<a>asdfsdf</a>"
    alert(test.document.body.innerHTML)
    test.document.body.innerHTML = "<b>asdfsdf</b>"
    alert(test.document.body.innerHTML)
    test.document.body.innerHTML = "<c>asdfsdf</c>"
    alert(test.document.body.innerHTML)
    }
    //-->
    </SCRIPT></body>
    </html>
      

  4.   

    你往body.innerHTML里面写内容,相当于<body>......</body>:function testIframe()
    {
    test.document.body.innerHTML = "asdfsdf"
    alert(test.document.body.outerHTML)
    }body对象里面当然放不进去html和body对象啦。function testIframe()
    {
    test.document.body.innerHTML = "<html>asdfsdf</html>"
    alert(test.document.body.outerHTML)
    }
      

  5.   

    emu(ston):
    我不想让浏览器对传入的内容重新解析,有可行的方法吗?
      

  6.   

    你往body.innerHTML里面写内容,相当于<body>......</body>:function testIframe()
    {
    test.document.body.innerHTML = "asdfsdf"
    alert(test.document.body.outerHTML)
    }body对象里面当然放不进去html和body对象啦。function testIframe()
    {
    test.document.body.innerHTML = "<html>asdfsdf</html>"
    alert(test.document.body.outerHTML)
    }
      

  7.   

    因为我需要在iframe中编辑html文件,所有不想让读入的文件丢失代码
      

  8.   

    不知道你的需求是如何,如果仅显示的话:
    idContent.document.body.innerText = document.form1.content.value;
    这样你看到的和字符串的结果一样。
    注意: innerText 和 innerHTML的区别,注意大小写.如果你想要的不是显示的话,那就把它变成变量.
    idContent.contentValue = document.form1.content.value;你会在idContent的iframe里得到contentValue变量,这是原封不动的。
      

  9.   

    不知道你的需求是如何,如果仅显示的话:
    idContent.document.body.innerText = document.form1.content.value;
    这样你看到的和字符串的结果一样。
    注意: innerText 和 innerHTML的区别,注意大小写.如果你想要的不是显示的话,那就把它变成变量.
    idContent.contentValue = document.form1.content.value;
    你会在idContent的iframe里得到contentValue变量,这是原封不动的。在iframe中编辑html文件的话:
    idContent.document.write(document.form1.content.value)
      

  10.   

    chenzengxi(懒猫),高手!!
     emu(ston) :多谢!
      

  11.   

    最好是:
    idContent.document.open();
    idContent.document.write(document.form1.content.value);
    idContent.document.close();