代码之家  ›  专栏  ›  技术社区  ›  AlexV

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

  •  11
  • AlexV  · 技术社区  · 14 年前

    如你所知 SWFObject offers 2 ways to embed Flash :静态发布和动态发布。

    静态发布 使用常规标记将文件嵌入到文档中,并使用JavaScript进行检查,这是单独使用常规标记无法做到的。这很好,因为如果您的客户无法打开JavaScript(搜索引擎、一些便携设备……),文件仍然会显示(如果他们安装了正确的Flash插件)。但是如果你有人在遗留/未修补的Internet Explorer上( between April 2006 and April 2008 )他们将有可怕的“点击激活”与闪光灯互动。

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

    两种方法都有其优点和不便之处。在一个乌托邦式的世界里,我们都会使用动态发布方法,但是我们(或者至少我们中的一些人和我一样)被那些使用IE 6的非常旧的系统的客户困住了(他们想升级,但是他们不能,因为设计不好的软件需要花费1万美元以上的升级费用)。我需要支持遗留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>
    

    我把它展示给一个集成者,他告诉我应该使用 <object> <embed> 标签。。。

    将Flash嵌入Web项目的最终方法是什么?解决方案:

    • 将在关闭JavaScript的情况下工作(在备用内容中嵌入Flash)
    • 将删除旧版/未修补IE上的“点击激活”

    编辑: 额外的赏金。拜托,我不想看到这样的答案:“不要打扰,现在没有人关闭JavaScript”或者“如果JavaScript关闭,Flash很可能也会关闭”。


    我要寻找的答案是静态嵌入Flash的最佳方式(使用常规HTML标记)。在此基础上,我将添加动态发布。什么 like this 全部的 主要浏览器,因为ie6和将通过W3C验证。


    7 回复  |  直到 7 年前
        1
  •  5
  •   Casey    12 年前
    <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/

        2
  •  3
  •   AlexV    14 年前

    <!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>
    
        3
  •  1
  •   Brad    14 年前

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

        4
  •  0
  •   spender    14 年前

    使用动态发布。如果用户关闭了javascript,请放弃。他们也不想让Flash运行。

        5
  •  0
  •   SteveCav Flater    14 年前

    有没有办法让你的客户在传统浏览器的旁边安装另一个浏览器(比如Firefox),并将IE6用于传统应用程序,FF用于你的应用程序?

        6
  •  0
  •   JoshNaro    14 年前

    来自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>
    
        7
  •  0
  •   choise    14 年前

    我看到的唯一方法是这样做:

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