将 Flash (swf) 文件嵌入到 HTML(和 XHTML)文档的最终方法是什么?

发布于 2024-09-08 15:48:45 字数 3164 浏览 1 评论 0 原文

与大多数人一样,我使用 SWFObject 将 Flash (swf) 文件嵌入到我的 Web 项目中。

如您所知,SWFObject 提供了 2 种嵌入 Flash 的方法:静态发布和动态发布。

静态发布使用常规标记将文件嵌入到文档中,并使用 JavaScript 进行检查,这是单独使用常规标记无法完成的。这很好,如果您的客户无法打开 JavaScript(搜索引擎、某些便携式设备...),该文件仍然会显示(如果他们安装了正确的 Flash 插件)。但是,如果您有人使用旧版/未修补的 Internet Explorer (2006 年 4 月至 2008 年 4 月之间)他们将遇到可怕的“点击激活”来与 Flash 交互。

动态发布使用JavaScript嵌入Flash。这将消除旧 IE 上的“点击激活”功能,但如果 JavaScript 关闭,Flash 将根本不存在。

两种方法都有其优点和缺点。在乌托邦世界中,我们都会使用动态发布方法,但是我们(或至少像我这样的一些人)被使用带有 IE 6 的非常旧的系统的客户所困扰(他们想要升级,但他们不能,因为严重设计的软件升级成本为 10K+$)。我需要支持旧版 IE,并希望摆脱“单击激活”功能,同时支持关闭 JavaScript 的用户。

结合静态动态发布方法怎么样?怎么样:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>SWFObject 2 static+dynamic publishing example page</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">
        swfobject.embedSWF("test.swf", "myContent", "300", "120", "9.0.0", "expressInstall.swf");
        </script>
    </head>
    <body>
        <div id="myContent">
            <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="120">
                <param name="movie" value="test.swf" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="test.swf" width="300" height="120">
                <!--<![endif]-->
                <div>
                    <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>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
        </div>
    </body>
</html>

我向集成商展示了这一点,他告诉我应该使用 标签......

最终的结果是什么如何将Flash嵌入到Web项目中?解决方案:

  • 将关闭 JavaScript(将 Flash 嵌入替代内容)
  • 将通过 W3C 验证器
  • 将删除旧版/未修补的 IE 上的“单击激活”
  • 将使用 Flash 检测/自动安装 SWFObject

编辑: 添加了赏金。拜托,我不想看到诸如“别打扰现在没有人关闭 JavaScript”或“如果 JavaScript 关闭,Flash 很可能也会关闭”之类的答案。


编辑2:我正在寻找的答案是静态嵌入Flash(使用常规HTML标签)的最佳方式。除此之外,我将添加动态发布。 像这样的东西可以在自 IE 6 以来的所有主要浏览器中使用将通过 W3C 验证。


Like most people I use SWFObject to embed Flash (swf) files to my Web projects.

As you know SWFObject offers 2 ways to embed Flash: Static publishing and Dynamic publishing.

Static publishing uses regular markup to embed the file to the document and also do checks with JavaScript that you can't make with regular markup alone. This is good as if you have customers that can't have JavaScript turned on (search engines, some portable devices...), the file will still show up (if they have the correct Flash plug-in installed). But if you have people on legacy/unpatched Internet Explorer (between April 2006 and April 2008) they will have the dreaded "click to activate" to interact with the Flash.

Dynamic publishing uses JavaScript to embed the Flash. This will get rid of the "click to activate" feature on old IE but if JavaScript is off the Flash will not be there at all.

Both methods have its advantages and inconvenients. In an utopic world we would all use the dynamic publishing method, but we (or at least some of us like me) are stuck with customers using really old systems with IE 6 (they would like to upgrade but they can't because of badly designed software that would cost 10K+$ to upgrade). I need to support legacy IE and want to get rid of the "click to activate" feature while supporting people with JavaScript off.

What about combining static and dynamic publishing methods? What about something like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <title>SWFObject 2 static+dynamic publishing example page</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">
        swfobject.embedSWF("test.swf", "myContent", "300", "120", "9.0.0", "expressInstall.swf");
        </script>
    </head>
    <body>
        <div id="myContent">
            <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="120">
                <param name="movie" value="test.swf" />
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="test.swf" width="300" height="120">
                <!--<![endif]-->
                <div>
                    <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>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
        </div>
    </body>
</html>

I showed that to an integrator and he told me I should use <object> and <embed> tags...

What would be the ultimate way to embed Flash to Web projects? A solution that:

  • Will work with JavaScript off (Flash embedded in alternate content)
  • Will pass the W3C validator
  • Will remove the "click to activate" on legacy/unpatched IE
  • Will use the Flash detection/auto-install of SWFObject

EDIT: Added bounty. Please, I don't want to see answers like "don't bother no one have JavaScript off nowdays" or "if javascript is off most likely Flash will be off too".


EDIT 2: The answer I'm looking for is the best way to embed Flash statically (with regular HTML tags). Over that, I will add dynamic publishing. Something like this that will work in all major browsers since IE 6 and that will pass W3C validation.


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

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

发布评论

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

评论(7

往昔成烟 2024-09-15 15:48:45
<head>
    <script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> 
    <script>
    var flashVars = {};
    var params = {};
        params.allowScriptAccess = "always";
        params.allowFullScreen = false;
        params.bgcolor = "#1a1a1a";
        params.wmode = "opaque";

        var atts = {};
        atts.id = "my-swf";

    swfobject.embedSWF("my.swf", "my-swfobject", "100%", "100%", "10.1.0", "playerProductInstall.swf", flashVars, params, atts);
    </script>
</head>
<body>
    <div id="my-swfobject">
        <!-- Any <object></object>, <embed></embed>, and everything else here will be rendered for users without JavaScript. If JavaScript is on, SWFObject will destroy div#my-swfobject and replace it with object#my-swf. -->
    </div>
</body>

如果这就是您要找的,请告诉我。如果需要的话我可以详细说明。您还可以考虑建议您的 IE6 从属设备安装 Google Chrome 浏览器内嵌框架:http://code.google.com /chrome/chromeframe/

<head>
    <script src="//ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> 
    <script>
    var flashVars = {};
    var params = {};
        params.allowScriptAccess = "always";
        params.allowFullScreen = false;
        params.bgcolor = "#1a1a1a";
        params.wmode = "opaque";

        var atts = {};
        atts.id = "my-swf";

    swfobject.embedSWF("my.swf", "my-swfobject", "100%", "100%", "10.1.0", "playerProductInstall.swf", flashVars, params, atts);
    </script>
</head>
<body>
    <div id="my-swfobject">
        <!-- Any <object></object>, <embed></embed>, and everything else here will be rendered for users without JavaScript. If JavaScript is on, SWFObject will destroy div#my-swfobject and replace it with object#my-swf. -->
    </div>
</body>

Let me know if this is what you're looking for. I can elaborate more if needed. You might also consider suggesting that your IE6 slaves install Google Chrome Frame: http://code.google.com/chrome/chromeframe/

心房的律动 2024-09-15 15:48:45

在这里:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
    <head>
        <title></title>
        <script type="text/javascript" src="swfobject.js"> </script>
        <script type="text/javascript">
            swfobject.embedSWF('test.swf', 'myFlash', '320', '240', '9.0.0', '/swfobject/expressInstall.swf', 0, 0, 0);
        </script>
    </head>
    <body>
        <div>
            <object id="myFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240">
                <param name="movie" value="test.swf">
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="test.swf" width="320" height="240">
                <!--<![endif]-->
                    <p>Version ???</p>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
        </div>
    </body>
</html>

Here it is:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
    <head>
        <title></title>
        <script type="text/javascript" src="swfobject.js"> </script>
        <script type="text/javascript">
            swfobject.embedSWF('test.swf', 'myFlash', '320', '240', '9.0.0', '/swfobject/expressInstall.swf', 0, 0, 0);
        </script>
    </head>
    <body>
        <div>
            <object id="myFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="320" height="240">
                <param name="movie" value="test.swf">
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="test.swf" width="320" height="240">
                <!--<![endif]-->
                    <p>Version ???</p>
                <!--[if !IE]>-->
                </object>
                <!--<![endif]-->
            </object>
        </div>
    </body>
</html>
娇纵 2024-09-15 15:48:45

我过去所做的是将 Flash 内容静态地放入 div 中(使用 object 和 embed 标签),然后让 SWFObject 在加载时覆盖该 div 的内容。这将尽可能接近您想要做的事情。

What I've done in the past is statically put my flash content in a div (using both object and embed tags), and then have SWFObject overwrite the contents of that div when it loads. This will be as close to what you want to do as you can get.

蘑菇王子 2024-09-15 15:48:45

采用动态发布。如果用户关闭了 javascript,则放弃。他们也不希望 Flash 运行。

Go with dynamic publishing. If the user has javascript turned off, give up. They won't want Flash to run either.

无边思念无边月 2024-09-15 15:48:45

有没有办法让您的客户在旧浏览器旁边安装另一种浏览器(例如 Firefox),并使用 IE6 作为旧应用程序,使用 FF 作为您的应用程序?

Is there a way to get your clients to install another browser (like Firefox) alongside their legacy one, and use IE6 for the legacy app and FF for yours?

深海里的那抹蓝 2024-09-15 15:48:45

我会从 YouTube 等允许嵌入 Flash 的网站中得到启发。不确定这是否适用于非“电影”类型。

来自 YouTube:

<object width="[width]" height="[height]">
<param name="movie" value="[Path to SWF]"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="[Path to SWF]" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="[width]" height="[height]"></embed>
</object>

I would take a cue from sites such as YouTube that allow embedding of Flash. Not sure if this will work for non "movie" types.

From YouTube:

<object width="[width]" height="[height]">
<param name="movie" value="[Path to SWF]"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="[Path to SWF]" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="[width]" height="[height]"></embed>
</object>
舂唻埖巳落 2024-09-15 15:48:45

我认为唯一的方法是做这样的事情:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title>test</title>
</head>
<body>
    <p>
        <object width="160" height="112" data="movie.swf" type="application/x-shockwave-flash">
            <param name="movie" value="movie.swf" />
        </object>
    </p>
</body>
</html>

我认为没有更好的选择。这适用于 IE、Mozilla 和 Webkit 浏览器,并且 xhtml 有效。但没有闪存安装程序,也没有替代品。

the only way i see, is doing something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title>test</title>
</head>
<body>
    <p>
        <object width="160" height="112" data="movie.swf" type="application/x-shockwave-flash">
            <param name="movie" value="movie.swf" />
        </object>
    </p>
</body>
</html>

there is no better option i think. this will work in IE , Mozilla and Webkit browsers and is xhtml valid. but there is no flash installer and no replacement.

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