我有这个遗留代码,它使用旧版本的SWFObject.js将SWF嵌入到HTML中:
var so = new SWFObject("main.swf", "main", "100%", "615", "9.0.115", "#000000");
so.addVariable("deeplink", deeplink);
so.addVariable("cid", cid);
so.addParam("scaleMode", "noscale");
so.addParam("allowScriptAccess", "always");
so.addParam("allowFullScreen", "true");
so.write("flashcontent");
我应该如何为最新的SWFObject.js重写它?我试过这个但是失败了,我想首先排除语法不匹配:
var mainSwfProperties = {
flashVars : {
cid : cid,
deeplink : deeplink
},
params : {
allowFullScreen : "true",
allowScriptAccess : "true",
scaleMode : "noscale",
wmode : "window"
},
attributes : {}
};
swfobject.embedSWF("main.swf", "flashcontent", "100%", 615, "9.0.115", null,
mainSwfProperties.flashVars,
mainSwfProperties.params,
mainSwfProperties.attributes
);
答案 0 :(得分:1)
嗯,我当然认为这样可行。基本上,flashvars,params和属性需要是js对象。我通常将它们留作单独的对象,而不是像你设置的那样只有一个对象。
<script type="text/javascript">
var flashvars = {cid:cid, deeplink:deeplink};
var params = {allowFullScreen:true, allowScriptAccess:true, scaleMode:"noscale", wmode:"window"};
var attributes = {}
swfobject.embedSWF("main.swf", "flashcontent", "100%", "615", "9.0.115", null, flashvars, params, attributes);
</script>
答案 1 :(得分:0)
同样来自swfobject文档,它希望宽度和高度为字符串,你的高度为int。