如何迁移SWFObject调用代码?
我有这样的旧代码,它使用旧版本的 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
);
I have this legacy code which embeds an SWF into an HTML using an old version of SWFObject.js:
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");
How should I rewrite it for the latest SWFObject.js? I have tried this but failed, and I would like to rule out the syntax-mismatch first:
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
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,我当然认为这会起作用。基本上,flashvars、params 和 attribute 需要是 js 对象。我通常将它们保留为单独的对象,而不是像您设置的那样使用单个对象。
Well, I would certainly think that would work. Basically, the flashvars, params, and attributes need to be js objects. I usually leave them as separate objects rather than having a single object like you have set uo.
同样从 swfobject 文档中,它期望宽度和高度是字符串,你在那里有一个 int 高度。
Also from the swfobject docs, it expects width and height to be strings, you have height as an int there.