对于当前的一个项目,我们正在使用SEO2.2来嵌入闪存文件,而CRD专家们正在使用SwfAddress 2.3来创建SwfObject闪存的好处。
事实证明,如果页面上同时包含了这两个库,则任何在API (http://code.google.com/p/swfobject/wiki/api)中使用SwfObject回调的尝试都会阻止SwfObject加载。在本例中,您可以简单地通过HTML注释掉SwfAddress文件来切换这一点。
抱歉,我无法在下面的代码中指向这两个库的绝对URL。
<head>
<title>SWFObject 2.2 dynamic embed with callback</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="swfaddress.js"></script>
<script type="text/javascript">
function outputStatus(e) {
alert("e.success = " + e.success +"\ne.id = "+ e.id +"\ne.ref = "+ e.ref);
}
var params = {};
params.allowscriptaccess = "always";
swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent1", "300", "120", "9.0.0", "expressInstall.swf", null, null);
swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent2", "300", "120", "9.0.0", "expressInstall.swf", null, params, null, outputStatus);
</script>
</head>
<body>
<div id="myContent1">
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
<div id="myContent2">
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
</body>
有什么想法吗?提前感谢!
发布于 2009-08-27 04:25:53
这是一个艰难的选择。
快速回答:您需要为flashVars和属性传递空对象,而不是"null“:(See my corrected demo code here)
swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent1", "300", "120", "9.0.0", "expressInstall.swf", {}, {});
swfobject.embedSWF("http://www.bobbyvandersluis.com/swfobject/testsuite_2_2/test6.swf", "myContent2", "300", "120", "9.0.0", "expressInstall.swf", {}, params, {}, outputStatus);完整的答案:深入研究SWFAddress源代码,他们正在重写SWFObject嵌入功能,这样他们就可以注入自己的功能。要做到这一点,他们必须做的一件事是将您传递的所有参数传递给他们自己的函数。您为attributes对象传递的"null“在下面的SWFAddress代码中导致错误:
var _s2e = swfobject.embedSWF;
swfobject.embedSWF = function() {
_args = arguments;
if (typeof _args[8] == UNDEFINED)
_args[8] = {};
if (typeof _args[8].id == UNDEFINED)
_args[8].id = _args[1]; // <-- ERROR here when this parameter (attributes) is null.
_s2e.apply(this, _args);
_ref.addId(_args[8].id);
}该错误导致整个第二次嵌入失败。
https://stackoverflow.com/questions/1296662
复制相似问题