IE中使用pasteHTML给对象插入flash代码param消失
<object type="application/x-shockwave-flash" data="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf" width="200" height="200" id="vcastr3" bgColor="#ff0000">
 <param name="movie" value="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf"/>
</object>
插入后<param name="movie" value="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf"/>
消失了,寻求解决办法。 

解决方案 »

  1.   

    确实消失了,不过可以正常播放啊你还要怎么?
    <html>
    <head>
     <title>Untitled</title>
     <style type="text/css">
        #div1 {
            width:500px;
            height:400px;
            border:solid 1px #09c;
        }
    </style>    
    </head>
    <body>
    ddddddd
    <div id="div1" contenteditable="true"  > </div> 
    </body>
    <script type="text/javascript">
    var g=function(id) {
        return typeof(id)==="string"?document.getElementById(id):id;
    };
    g("div1").onkeypress=function() {
        if(window.event && window.event.keyCode==13) {
            with(document.selection.createRange()) {
                pasteHTML('<object type="application/x-shockwave-flash" data="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf" width="200" height="200" id="vcastr3" bgColor="#ff0000"><param name="movie" value="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf"/></object>');
                select();              
            }
            //alert(this.innerHTML);
            return window.event.returnValue=false;
        }
    }
    </script>
    </html>
      

  2.   

    <html>
    <head>
     <title>Untitled</title>
     <style type="text/css">
        div {
            width:500px;
            height:400px;
            border:solid 1px #09c;
        }
    </style>    
    </head>
    <body>
    ddddddd
    <div id="div1" contenteditable="true"  > </div> 
    <div id="div2"   > </div> 
    </body>
    <script type="text/javascript">
    var g=function(id) {
        return typeof(id)==="string"?document.getElementById(id):id;
    };
    g("div1").onkeypress=function() {
        if(window.event && window.event.keyCode==13) {
            with(document.selection.createRange()) {
                pasteHTML('<object type="application/x-shockwave-flash" data="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf" width="200" height="200" id="vcastr3" bgColor="#ff0000"><param name="movie" value="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf"/></object>');
                select();              
            }
            document.getElementById("div2").innerHTML=this.innerHTML;
            return window.event.returnValue=false;
        }
    }
    </script></html>
    但是如果这样div2中的flash就不能播放了啊。
      

  3.   

    你难道一个页面里还要用几个相同的flash么?
    或者你直接用innerHTML,何必要这么麻烦 呢?var tag='<object type="application/x-shockwave-flash" data="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf" width="200" height="200" id="vcastr3" bgColor="#ff0000"><param name="movie" value="http://player.youku.com/player.php/sid/XMTM1NzI2NjE2/v.swf"/></object>'
    document.getElementById("div1").innerHTML=tag; 
    document.getElementById("div2").innerHTML=tag; 
      

  4.   

    研究下编辑器,插入flash,所以只有这么搞了,谢谢哥们了。
      

  5.   

    如果只是插入flash可以使用这个标签,<embed src="http://www.dd.swf" type="application/x-shockwave-flash" play="true" loop="true" menu="true"></embed>
      

  6.   

    我主要想搞个兼容的火狐和ie的,火狐下用execCommand插入不了<embed src="http://www.dd.swf" type="application/x-shockwave-flash" play="true" loop="true" menu="true"></embed>
    现在只有分开搞了。