像这样的可以显示出来flashdocument.write('<body>');
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="680" height="75"> ');
    document.write('<param name="movie" value="flash/banner.swf">');
    document.write('<param name="quality" value="high"> ');
    document.write('<param name="wmode" value="transparent"> ');
    document.write('<param name="menu" value="false"> ');     document.write('<embed src="flash/banner.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="680" height="75"></embed> ');
    document.write('</object> ');
    document.write('</body>');但是现在不知道用document.createElement("object")要怎么显示出来flash,请高手进来指导,我自己对JS还不是很熟悉,有很多不懂的地方,还希望大家指导!在线~

解决方案 »

  1.   

    document.createElement("object")这样写没有用过,所以不知道要怎么写?
      

  2.   

    直接<object src="路径"></object>不可以吗?
      

  3.   

    那样做是可以的,但是我现在必须document.createElement("object")这样写呀?
      

  4.   

    你createElement出来上面所有的标签<param,并设置属性,创建的结果与上面相同就应当可以显示。不过,使用createElement更繁琐
      

  5.   

    <script>
    function getSwf(){
    var div=document.createElement("div");
    var codes=[];
    var swf;

    codes.push('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="680" height="75"> ');
    codes.push('<param name="movie" value="http://img1.126.net/channel5/007393/20300_100422.swf">');
    codes.push('<param name="quality" value="high"> ');
    codes.push('<param name="wmode" value="transparent"> ');
    codes.push('<param name="menu" value="false"> '); 

    codes.push('<embed src="http://img1.126.net/channel5/007393/20300_100422.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="680" height="75"></embed> ');
    codes.push('</object> ');

    div.style.cssText="display:none;"
      div.innerHTML=codes.join("");
      swf=div.removeChild(div.getElementsByTagName("object")[0]);
      div=null;
      return swf;    
    } function showSwf(){
        //var div=document.createElement("div");
        //div.style.cssText="width:500px;height:300px;border:1px solid red;"
      document.body.appendChild(getSwf());
    }
    </script>
    <input type="button" value="添加Flash" onclick="showSwf()"/>
      

  6.   

    推荐看一下 深入浅出JavaScript
      

  7.   

     9 楼 xingqiliudehuanghun 
    但是我现在必须document.createElement("object")这样写呀?不知道这种方法要怎么写?
      

  8.   

    我也在网上找了好多例子,都是document.write()的,蛮少有document.createElement("object")这种写法,郁闷呀!
      

  9.   


    <script type="text/javascript">
    function foo(){
    var o={width:'680',height:'75',src:'http://img1.126.net/channel5/007427/118118_100519.swf'} var obj=document.createElement('object');
    var param;
    obj.classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
    obj.codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";
    obj.width=o.width;
    obj.height=o.height;

    param=document.createElement('param');
    param.name="movie";
    param.value=o.src;
    obj.appendChild(param);

    param=document.createElement('param');
    param.name="quality"
    param.value="high"
    obj.appendChild(param);

    param=document.createElement('param');
    param.name="wmode"
    param.value="transparent"
    obj.appendChild(param);

    param=document.createElement('param');
    param.name="menu"
    param.value="false"
    obj.appendChild(param); param=document.createElement('embed');
    param.src=o.src;
    param.quality="high";
    param.pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
    param.type="application/x-shockwave-flash"
    param.width=o.width;
    param.height=o.height;
    obj.appendChild(param);
    document.body.appendChild(obj);
    }
    foo();
    </script>以上代码,firefox可用,chrome可用,opera可用,ie6不可用(ie其他版本未测,不过猜测应该不可用)
      

  10.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><body onload="foo();">
    <script type="text/javascript">
    function foo(){
        var o={width:'680',height:'75',src:'http://img1.126.net/channel5/007427/118118_100519.swf'}    var obj=document.createElement('object');
        var param;
    obj.setAttribute('classid','clsid:D27CDB6E-AE6D-11cf-96B8-444553540000')
    obj.setAttribute('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0');
    obj.setAttribute('width',o.width)
    obj.setAttribute('height',o.height)
        
        param=document.createElement('param');
    param.setAttribute('name',"movie")
    param.setAttribute('value',o.src)
        obj.appendChild(param);
        
        param=document.createElement('param');
    param.setAttribute('name',"quality")
    param.setAttribute('value',"high")
        obj.appendChild(param);
        
        param=document.createElement('param');
    param.setAttribute('name',"wmode")
    param.setAttribute('value',"transparent")
        obj.appendChild(param);
        
        param=document.createElement('param');
    param.setAttribute('name',"menu")
    param.setAttribute('value',"false")
        obj.appendChild(param);    param=document.createElement('embed');
    param.setAttribute('width',o.width)
    param.setAttribute('height',o.height)
    param.setAttribute('src',o.src)
        param.setAttribute('quality',"high")
        param.setAttribute('pluginspage',"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash")
    param.setAttribute('type',"application/x-shockwave-flash")
        obj.appendChild(param);    
        document.body.appendChild(obj);
    }
    </script>
    </body>
    </html>以上代码同样,firefox可用,chrome可用,opera可用,ie6不可用(ie其他版本未测,不过猜测应该不可用)