如何在 HTML 页面中嵌入 SWF 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/137326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:23:49  来源:igfitidea点击:

How to embed a SWF file in an HTML page?

htmlembedflash

提问by MetaGuru

How do you embed a SWF file in an HTML page?

如何在 HTML 页面中嵌入 SWF 文件?

采纳答案by Ronnie Liew

The best approach to embed a SWF into an HTML page is to use SWFObject.

将 SWF 嵌入 HTML 页面的最佳方法是使用SWFObject

It is a simple open-source JavaScript library that is easy-to-use and standards-friendly method to embed Flash content.

它是一个简单的开源 JavaScript 库,是一种易于使用且符合标准的嵌入 Flash 内容的方法。

It also offers Flash player version detection. If the user does not have the version of Flash required or has JavaScript disabled, they will see an alternate content. You can also use this library to trigger a Flash player upgrade. Once the user has upgraded, they will be redirected back to the page.

它还提供 Flash 播放器版本检测。如果用户没有所需的 Flash 版本或禁用了 JavaScript,他们将看到替代内容。您还可以使用此库来触发 Flash 播放器升级。用户升级后,他们将被重定向回该页面。

An example from the documentation:

文档中的一个示例:

<!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 dynamic embed - step 3</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("myContent.swf", "myContent", "300", "120", "9.0.0");
    </script>

  </head>
  <body>
    <div id="myContent">
      <p>Alternative content</p>
    </div>
  </body>
</html>

A good tool to use along with this is the SWFObject HTML and JavaScript generator. It basically generates the HTML and JavaScript you need to embed the Flash using SWFObject. Comes with a very simple UI for you to input your parameters.

与此一起使用的一个好工具是 SWFObject HTML 和 JavaScript生成器。它基本上生成使用 SWFObject 嵌入 Flash 所需的 HTML 和 JavaScript。带有一个非常简单的用户界面供您输入参数。

It Is highly recommended and very simple to use.

强烈推荐使用它并且非常简单。

回答by ólafur Waage

<object width="100" height="100">
    <param name="movie" value="file.swf">
    <embed src="file.swf" width="100" height="100">
    </embed>
</object>

回答by Jan Desta

How about simple HTML5 tag embed?

简单的 HTML5 标签嵌入怎么样?

<!DOCTYPE html>
<html>
<body>

<embed src="anim.swf">

</body>
</html>

回答by Spooky

This is suitable for application from root environment.

这适用于从 root 环境应用程序。

<object type="application/x-shockwave-flash" data="/dir/application.swf" 
id="applicationID" style="margin:0 10px;width:auto;height:auto;">

<param name="movie" value="/dir/application.swf" />
<param name="wmode" value="transparent" /> <!-- Or opaque, etc. -->

<!-- ↓ Required paramter or not, depends on application -->
<param name="FlashVars" value="" />

<param name="quality" value="high" />
<param name="menu" value="false" />

</object>

Additional parameters should be/can be added which depends on .swf it self. No embed, just objectand parameters within, so, it remains valid, working and usable everywhere, it doesn't matter which !DOCTYPE is all about. :)

应该/可以添加其他参数,这取决于 .swf 本身。没有 embed,只有对象和参数,因此,它在任何地方都保持有效、工作和可用,无论 !DOCTYPE 是关于哪个都无关紧要。:)

回答by Spooky

<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/VhtIydTmOVU&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01" 
style="width:640px;height:480px;margin:10px 36px;">

<param name="movie" value="http://www.youtube.com/v/VhtIydTmOVU&amp;hl=en&amp;fs=1&amp;color1=0xe1600f&amp;color2=0xfebd01" />
<param name="allowfullscreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="wmode" value="opaque" />
<param name="quality" value="high" />
<param name="menu" value="false" />

</object>

回答by Brian Kim

If you are using one of those js libraries to insert Flash, I suggest adding plain object embed tag inside of <noscript/>.

如果您使用这些 js 库之一来插入 Flash,我建议在<noscript/>.

回答by Eduardo Campa?ó

I use http://wiltgen.net/objecty/, it helps to embed media content and avoid the IE "click to activate" problem.

我使用http://wiltgen.net/objecty/,它有助于嵌入媒体内容并避免 IE 的“点击激活”问题。

回答by phatduckk

As mentioned SWF Object is great. UFOis worth a look as well

如前所述,SWF 对象很棒。UFO也值得一看

回答by Stefan ?or?evi?

This one will work, I am sure!

这个会奏效的,我相信!

<embed src="application.swf" quality="high" pluginspage="http://www.macromedia.com/go/getfashplayer" type="application/x-shockwave-flash" width="690" height="430">

回答by Isuru Dilshan

I know this is an old question. But this answer will be good for the present.

我知道这是一个老问题。但是这个答案对现在来说是有益的。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>histo2</title>
        <style type="text/css" media="screen">
        html, body { height:100%; background-color: #ffff99;}
        body { margin:0; padding:0; overflow:hidden; }
        #flashContent { width:100%; height:100%; }
        </style>
    </head>
    <body>
        <div id="flashContent">
            <object type="application/x-shockwave-flash" data="histo2.swf" width="822" height="550" id="histo2" style="float: none; vertical-align:middle">
                <param name="movie" value="histo2.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#ffff99" />
                <param name="play" value="true" />
                <param name="loop" value="true" />
                <param name="wmode" value="window" />
                <param name="scale" value="showall" />
                <param name="menu" value="true" />
                <param name="devicefont" value="false" />
                <param name="salign" value="" />
                <param name="allowScriptAccess" value="sameDomain" />
                <a href="http://www.adobe.com/go/getflash">
                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                </a>
            </object>
        </div>
    </body>
</html>