SwfAddress 与 SwfObject 的“回调”冲突;争论

发布于 2024-08-03 02:28:27 字数 2007 浏览 6 评论 0原文

对于当前的项目,我们使用 SwfObject 2.2 嵌入 Flash 文件,CRD 专家使用 SwfAddress 2.3 来创建 SEO Flash 优势。

事实证明,如果页面上包含这两个库,则在 API 中使用 SwfObject 回调的任何尝试 (http://code.google.com/p/swfobject/wiki/api) 阻止 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>

有什么想法吗?提前致谢!

For a current project we are using SwfObject 2.2 to embed flash files, and the CRD gurus are using SwfAddress 2.3 to create SEO flash goodness.

Turns out that if you have both libraries included on a page, then any attempts at using SwfObject callback in the API (http://code.google.com/p/swfobject/wiki/api) prevents the SwfObject loading. In the example you can toggle this simply by HTML commenting out the SwfAddress file.

Sorry I couldn't point to absolute URLs for these two libraries in my code below.

<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>

Any ideas? Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

背叛残局 2024-08-10 02:28:28

这是一场艰难的比赛。

快速回答:您需要为 flashVars 和属性传递空对象而不是“null”:(请参阅我的此处更正了演示代码

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 嵌入功能,以便可以注入自己的功能。为此,他们必须做的事情之一是将您传入的所有参数传输到他们自己的函数中。您为属性对象传递的“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);
    }

该错误导致整个第二次嵌入失败。

This was a tough one.

Quick answer: You need to pass empty objects instead of "null" for the flashVars and attributes: (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);

Full answer: Digging into the SWFAddress source code, they are rewriting the SWFObject embed functionality so they can inject their own. One of the things they have to do to do this is transfer all of the parameters you pass in to their own function. The "null" you were passing for the attributes object was causing an error in the SWFAddress code here:

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);
    }

The error caused the whole second embed to fail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文