1. object + embed       传统的方法

优点:浏览器兼容性好,是 Macromedia 一直以来的官方方法
缺点:
a.embed 标签是不符合 W3C 的规范的,无法通过验证。当然,如果你不在乎什么规范不规范,另当别论。
b.微软由于种种原因,在 sp2 后限制了 IE 的 ActiveX 的使用模式,就是在页面中的 ActiveX 有一个虚框,需要用户点击一次才能正常交互。Flash是作为一个 ActiveX 嵌入到网页中的,所以它也会受牵连,只有通过 JS 嵌入 Flash 才能解决这个问题。
c.没有 Flash 版本检测,如果版本浏览器的flash插件版本不够,或者不能正常显示你的 swf 文件,或者会弹出一个 ActiveX 的确认安装的框。

<object id="forfun" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">
<param name="movie" value="/seufld/seufld/flash/focus2.swf">
<param name="quality" value="high">
<param name="bgcolor" value="#F0F0F0">
<param name="menu" value="false">
<param name="wmode" value="opaque"><!--Window|Opaque|Transparent-->
<param name="FlashVars" value="">
<param name="allowScriptAccess" value="sameDomain">
<embed id="forfunex" src="/seufld/seufld/flash/focus2.swf"
width="400"
height="300"
align="middle"
quality="high"
bgcolor="#f0fff8"
menu="false"<!--添加后,ff下才正常-->
play="true"
loop="false"
FlashVars=""
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>

================分割线================

2. 单object

这种方法的名字叫做 Flash satay,最早是2002年由 Drew McLellan 发表在 A List Apart 上,后来又经过了几次完善:

<object type="application/x-shockwave-flash" data="c.swf?path=movie.swf"
width="400" height="300">
<param name="movie" value="c.swf?path=movie.swf" />
<img src="http://xuguangzhi2003.blog.163.com/blog/noflash.gif" width="200" height="100" alt="" />
</object>

优点:这方法没有embed,可以通过验证,浏览器兼容性也不错
缺点:
a.需要一个 holder swf 来加载你的目标 swf 以保证 IE 中的 stream 能力,如果你需要通过 flashvars 来传参,或者和页面的 JS 交互,会很麻烦。
b.ActiveX的虚框问题。
c.没有版本检测。
d.还是有少数用户代理(比如一些版本的 safari 和一些屏幕阅读器)不认这种方式,有 bug。

================分割线================

3. 双object

<object id="exercises" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="214" height="144">
<param name="movie" value="${contextPath}/flex/photo.swf" />
<param name="wmode" value="window" />
<param name="flashvars" value=""/>
<!--[if !IE]><!-->
<object id="exercisesEx" type="application/x-shockwave-flash"
data="${contextPath}/flex/photo.swf" width="214" height="144">
<param name="flashvars" value=""/>
<!--<![endif]-->
<!--[if gte IE 6]>
<![endif]-->
<!--[if !IE]><!-->
<!--<![endif]-->
<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>
<!--[if !IE]><!-->
</object>
<!--<![endif]-->
</object>

================分割线================

4. flex提供的标准方法

<!-- BEGIN Browser History required section -->
<link rel="stylesheet" type="text/css" href="http://xuguangzhi2003.blog.163.com/blog/history/history.css" />
<!-- END Browser History required section --> <script src="http://xuguangzhi2003.blog.163.com/blog/AC_OETags.js" language="javascript"></script> <!-- BEGIN Browser History required section -->
<script src="http://xuguangzhi2003.blog.163.com/blog/history/history.js" language="javascript"></script>
<!-- END Browser History required section --> <style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 9;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 60;
// -----------------------------------------------------------------------------
// -->
</script>
</head> <body scroll="no">
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6, 0, 65); // Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision); if ( hasProductInstall && !hasRequestedVersion ) {
// DO NOT MODIFY THE FOLLOWING FOUR LINES
// Location visited after installation is complete if installation is required
var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
var MMdoctitle = document.title; AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "100%",
"height", "100%",
"align", "middle",
"id", "ManagePlatform",
"quality", "high",
"bgcolor", "#869ca7",
"name", "ManagePlatform",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else if (hasRequestedVersion) {
// if we've detected an acceptable version
// embed the Flash Content SWF when all tests are passed
AC_FL_RunContent(
"src", "ManagePlatform",
"width", "100%",
"height", "100%",
"align", "middle",
"id", "ManagePlatform",
"quality", "high",
"bgcolor", "#869ca7",
"name", "ManagePlatform",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else { // flash is too old or we can't detect the plugin
var alternateContent = 'Alternate HTML content should be placed here. '
+ 'This content requires the Adobe Flash Player. '
+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
document.write(alternateContent); // insert non-flash content
}
// -->
</script>
<noscript>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="ManagePlatform" width="100%" height="100%"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="ManagePlatform.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#869ca7" />
<param name="allowScriptAccess" value="sameDomain" />
<embed src="http://xuguangzhi2003.blog.163.com/blog/ManagePlatform.swf" quality="high" bgcolor="#869ca7"
width="100%" height="100%" name="ManagePlatform" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>
</noscript>

================分割线================

5. swfobject

http://code.google.com/p/swfobject/

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>SWFObject 2 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">
<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>
</html>

================分割线================

6. 单embed显示 ie7和ff3下都能正常显示

<embed allowscriptaccess="never" allownetworking="internal" invokeurls="false" src="http://chabudai.sakura.ne.jp/blogparts/honehoneclock/honehone_clock_tr.swf" 
pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" autostart="0" wmode="transparent" width="100%"
height="300" align="middle">

网页中嵌入swf文件的几种方法的更多相关文章

  1. html中嵌入swf文件的几种方法

    转自:http://blog.163.com/yuki_1154/blog/static/7120277120126109315935/ 找了很久终于找到一个比较全面的: 1. object + em ...

  2. .net中创建xml文件的两种方法

    .net中创建xml文件的两种方法 方法1:根据xml结构一步一步构建xml文档,保存文件(动态方式) 方法2:直接加载xml结构,保存文件(固定方式) 方法1:动态创建xml文档 根据传递的值,构建 ...

  3. 网页中插入外部视频的几种方法(PC与手机网页通用)

    网页中加入视频的几种方法(PC与手机网页通用) 方法一: <!doctype html> <html> <head> <meta charset=" ...

  4. 【转】flash air中读取本地文件的三种方法

    actionscript中读取本地文件操作有两种代码如下 1.使用File和FileStream两个类,FileStream负责读取数据的所以操作:(同步操作) var stream:FileStre ...

  5. VC下遍历文件夹中的所有文件的几种方法

    一.使用::FindFirstFile和::FindNextFile方法 #include "StdAfx.h" #include <windows.h> #inclu ...

  6. java中调用dll文件的两种方法

    一中是用JNA方法,另外是用JNative方法,两种都是转载来的, JNA地址:http://blog.csdn.net/shendl/article/details/3589676   JNativ ...

  7. Magento中调用JS文件的几种方法

    一.全局调用方法: 通过该方法每个页面都会引用这个JS文件,除非是类似jQuery这样的系统文件,不然不推荐这种方法. 文件路径:/app/design/frontend/default/Your_T ...

  8. MVC 中引入Jquery文件的几种方法

    方法1: <script src="@Url.Content("~/Scripts/jquery-1.9.1.js")" type="text/ ...

  9. node服务器中打开html文件的两种方法

    方法1:利用 Express 托管静态文件,详情查看这里 方法2:使用fs模块提供的readFile方法打开文件,让其以text/html的形式输出. 代码: var express = requir ...

随机推荐

  1. Qt4程序在windows平台下打包发布

    一.打包成绿色版 将源码编译成release版,运行*.exe文件,提示缺少*.dll,在Qt安装目录中找到相应的dll文件(一般在bin目录下),将dll文件复制到exe文件目录下即可. 二.打包成 ...

  2. 【uoj#37/bzoj3812】[清华集训2014]主旋律 状压dp+容斥原理

    题目描述 求一张有向图的强连通生成子图的数目对 $10^9+7$ 取模的结果. 题解 状压dp+容斥原理 设 $f[i]$ 表示点集 $i$ 强连通生成子图的数目,容易想到使用总方案数 $2^{sum ...

  3. Eclipse中设置新创建文件的默认编码格式

    window-prefenences-web-jsp(或者是其他文件格式,里面是一个列表) 找到之后点击,在右侧区域中选择encoding进行修改即可,然后应用,OK

  4. 【Cf #178 A】Shaass and Lights(组合数)

    考虑两个灯之间的暗灯,能从左边或右边点亮两种顺序,而最左端或最右端只有一种点亮顺序. 先不考虑点灯顺序,总共有n - m个灯要点亮,对于连续的一段暗灯,他们在总的点灯顺序中的是等价的,于是问题就可以抽 ...

  5. loj2542 「PKUWC2018」随机游走 【树形dp + 状压dp + 数学】

    题目链接 loj2542 题解 设\(f[i][S]\)表示从\(i\)节点出发,走完\(S\)集合中的点的期望步数 记\(de[i]\)为\(i\)的度数,\(E\)为边集,我们很容易写出状态转移方 ...

  6. 【poj3623】 Best Cow Line, Gold

    http://poj.org/problem?id=3623 (题目链接) 题意 给出一个字符串,每次可以取首或尾接到一个新的字符串后面,求构出的字典序最小的新字符串. Solution 首先可以发现 ...

  7. java的序列化流和打印流

    对象操作流(序列化流) 每次读取和写出的都是JavaBean对象. 序列化:将对象写入到文件中的过程 反序列化:从文件中读取对象到程序的过程 transient: 标识瞬态,序列化的时候,该修饰符修饰 ...

  8. 星号三角形 I

    N = int(eval(input())) for row in range(1,N+1): if row%2 != 0: a = '*'*row print ('{}'.format(a.cent ...

  9. Java泛型底层源码解析--ConcurrentHashMap(JDK1.7)

    1. Concurrent相关历史 JDK5中添加了新的concurrent包,相对同步容器而言,并发容器通过一些机制改进了并发性能.因为同步容器将所有对容器状态的访问都串行化了,这样保证了线程的安全 ...

  10. Java基础-面向对象第二特征之继承(Inheritance)

    Java基础-面向对象第二特征之继承(Inheritance) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.继承的概述 在现实生活中,继承一般指的是子女继承父辈的财产.在程序 ...