无法使用swfobject将Flash添加到HTML

时间:2013-02-15 06:06:13

标签: javascript flash swfobject

帮助我,我差点儿疯了...... 关键代码在下面,它不起作用,“对象”中没有任何内容:

    var obj=document.createElement('object');
    obj.id="FlashFormulaEditor";
    obj.width="520";
    obj.height="500";
    document.body.appendChild(obj);
    table.appendChild(obj);
    var swfVersionStr = "9.0.0";
    // To use express install, set to playerProductInstall.swf, otherwise the empty string. 
    var xiSwfUrlStr = "";
    var flashvars = {};
    var params = {};
    params.quality = "high";
    params.bgcolor = "#ffffff";
    params.allowscriptaccess = "sameDomain";
    params.allowfullscreen = "true";
    var attributes = {};
    attributes.id = "FlashFormulaEditor";
    attributes.name = "FlashFormulaEditor";
    attributes.align = "middle";
    swfobject.embedSWF("./FlashFormulaEditor.swf", "FlashFormulaEditor",  "475", "552", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);

1 个答案:

答案 0 :(得分:1)

尝试一下:

function initFlash(){
            var flashvars = {};
            var params = {};
            var attributes = {};
            params.quality = "high";
            params.play = "true";
            params.loop = "true";
            params.wmode = "transparent";
            params.scale = "showall";
            params.menu = "false";
            params.devicefont = "true";
            params.salign = "";
            params.allowScriptAccess = "always";
            params.allowFullScreen = "true";
            attributes.id = "swfLoader";
            attributes.name = "swfLoader";
            swfobject.embedSWF("your.domain/flash.swf", "flashContent", "100%", "100%", "11", false, flashvars, params, attributes);
        }

只需在你的div中添加一个id('flashContent')。希望这会有所帮助。