innerHTML浏览器会解析,不符合DOM关系的全部会被去掉,要保留什么东西得具体写下

解决方案 »

  1.   

    像情况一,可能不知道用户指定了什么属性。所以具体写也有难度。有可能是realplay对象,还有可能是其它的。
      

  2.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>
    test
    </title>
    <script type="text/javascript">
    function test() {
            var content = document.body.innerHTML;
            document.body.innerHTML = content;
            MediaPlayer.ShowStatusBar=true;
            MediaPlayer.Filename="http://www.liaozhong.cn/tp/news/200612/20061231356243392.mp3"
    }
    </script>
    </head>
    <body onload="test()">
    <object align=middle classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 class=OBJECT id=MediaPlayer width=300 height=50>
    <param name=ShowStatusBar value=-1>
    <param name=Filename value=http://www.liaozhong.cn/tp/news/200612/20061231356243392.mp3>
    <embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src="http://www.liaozhong.cn/tp/news/200612/20061231356243392.mp3" width=300 height=50></embed></object>
    </body>
    </html>
    情况一我是这样解决的,可是有的时候连MediaPlayer这个对象的ID都不知道
      

  3.   

    如何用innerHTML中的javascript代码执行?
    问题如下,当执行t()方法时,iframe会变为不可编辑,如果将body内的js脚本复制到t()方法中,可以使iframe变为可编辑。现在的问题是,不知道body会执行什么js代码,请问能不能不用复制js代码的方法解决这个问题?
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>test</title>
    <style type="text/css">
    td.TableBody2{background-color: #E4E8EF;}
    .tableBorder1{width:98%;border: 1px; background-color: #6595D6;}
    </style>
    <script type="text/javascript">
    function t() {
        document.body.innerHTML = document.body.innerHTML;
    }
    </script>
    </head>
    <body onload="t()">
    <iframe id="Composition" width="450" height="300"></iframe>
    <script type="text/javascript">
    var IsIE5 = document.all;
    if (IsIE5)
    {
        var IframeID = frames["Composition"];
    } else {
        var IframeID = document.getElementById("Composition").contentWindow;
    }
    var editor = IframeID;
    editor.document.open();
    editor.document.write ('<html><head>');
    editor.document.write ("</head><body></body>");
    editor.document.write ("</html>");
    editor.document.close();
    editor.document.body.contentEditable = "True";
    </script>
    </body>
    </html>