1. object + embed       传统的方法

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

<objectid="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"><paramname="movie"value="/seufld/seufld/flash/focus2.swf"><paramname="quality"value="high"><paramname="bgcolor"value="#F0F0F0"><paramname="menu"value="false"><paramname="wmode"value="opaque"><!--Window|Opaque|Transparent--><paramname="FlashVars"value=""><paramname="allowScriptAccess"value="sameDomain"><embedid="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 上,后来又经过了几次完善:

<objecttype="application/x-shockwave-flash"data="c.swf?path=movie.swf"width="400"height="300">
<paramname="movie"value="c.swf?path=movie.swf" />
<imgsrc="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

<objectid="exercises"classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"width="214"height="144"><paramname="movie"value="${contextPath}/flex/photo.swf" /><paramname="wmode"value="window" /><paramname="flashvars"value=""/><!--[if !IE]><!--><objectid="exercisesEx"type="application/x-shockwave-flash"data="${contextPath}/flex/photo.swf"width="214"height="144"><paramname="flashvars"value=""/><!--<![endif]--><!--[if gte IE 6]><![endif]--><!--[if !IE]><!--><!--<![endif]--><ahref="http://www.adobe.com/go/getflashplayer"><imgsrc="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-->
<linkrel="stylesheet"type="text/css"href="http://xuguangzhi2003.blog.163.com/blog/history/history.css" />
<!--END Browser History required section--><scriptsrc="http://xuguangzhi2003.blog.163.com/blog/AC_OETags.js"language="javascript"></script><!--BEGIN Browser History required section-->
<scriptsrc="http://xuguangzhi2003.blog.163.com/blog/history/history.js"language="javascript"></script>
<!--END Browser History required section--><style>body{margin:0px;overflow:hidden}</style>
<scriptlanguage="JavaScript"type="text/javascript"><!--//-----------------------------------------------------------------------------//Globals//Major version of Flash requiredvarrequiredMajorVersion= 9;//Minor version of Flash requiredvarrequiredMinorVersion= 0;//Minor version of Flash requiredvarrequiredRevision= 60;//-----------------------------------------------------------------------------//--></script>
</head><bodyscroll="no">
<scriptlanguage="JavaScript"type="text/javascript"><!--//Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)varhasProductInstall=DetectFlashVer(6,0,65);//Version check based upon the values defined in globalsvarhasRequestedVersion=DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);if( hasProductInstall&& !hasRequestedVersion ) {//DO NOT MODIFY THE FOLLOWING FOUR LINES//Location visited after installation is complete if installation is requiredvarMMPlayerType=(isIE== true)? "ActiveX":"PlugIn";varMMredirectURL=window.location;document.title=document.title.slice(0,47)+ "- Flash Player Installation";varMMdoctitle=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 passedAC_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 pluginvaralternateContent= '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><objectclassid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"id="ManagePlatform"width="100%"height="100%"codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab"><paramname="movie"value="ManagePlatform.swf" /><paramname="quality"value="high" /><paramname="bgcolor"value="#869ca7" /><paramname="allowScriptAccess"value="sameDomain" /><embedsrc="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/

<htmlxmlns="http://www.w3.org/1999/xhtml"lang="en"xml:lang="en"><head><title>SWFObject 2 dynamic publishing example page</title><metahttp-equiv="Content-Type"content="text/html; charset=iso-8859-1" /><scripttype="text/javascript"src="swfobject.js"></script><scripttype="text/javascript">swfobject.embedSWF("test.swf","myContent","300","120","9.0.0","expressInstall.swf");</script></head><body><divid="myContent"><h1>Alternative content</h1><p><ahref="http://www.adobe.com/go/getflashplayer"><imgsrc="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下都能正常显示

<embedallowscriptaccess="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">
================华丽分割线================

flash wmode参数详解

在做web开发中可能会遇到flash遮挡页面中元素的情况,无论怎么设置flash容器和层的深度(z-index)也无济于事,现有的解决方案是在插入flash的embed或object标签中加入”wmode”属性并设置为wmode=“transparent”或”opaque”,但wmode属性到底是什么意义,为什么可以解决这个问题呢?window mode(wmode)wmode即窗口模式总共有三种,看看当年Macromedia官方的说法:
  • Window: Use the Window value to play a Flash Player movie in its own rectangular window on a web page. This is the default value for wmode and it works the way the classic Flash Player works. This normally provides the fastest animation performance.
  • Opaque: By using the Opaque value you can use JavaScript to move or resize movies that don’t need a transparent background. Opaque mode makes the movie hide everything behind it on the page. Additionally, opaque mode moves elements behind Flash movies (for example, with dynamic HTML) to prevent them from showing through.
  • Transparent: Transparent mode allows the background of the HTML page, or the DHTML layer underneath the Flash movie or layer, to show through all the transparent portions of the movie. This allows you to overlap the movie with other elements of the HTML page. Animation performance might be slower when you use this value.
window 模式默认情况下的显示模式,在这种模式下flash player有自己的窗口句柄,这就意味着flash影片是存在于Windows中的一个显示实例,并且是在浏览器核心显示窗口之上的,所以flash只是貌似显示在浏览器中,但这也是flash最快最有效率的渲染模式。由于他是独立于浏览器的HTML渲染表面,这就导致默认显示方式下flash总是会遮住位置与他重合的所有DHTML层。但是大多数苹果电脑浏览器会允许DHTML层显示在flash之上,但当flash影片播放时会出现比较诡异的现象,比如DHTML层像被flash刮掉一块一样显示异常。Opaque 模式这是一种无窗口模式,在这种情况下flash player没有自己的窗口句柄,这就需要浏览器需要告诉flash player在浏览器的渲染表面绘制的时间和位置。这时flash影片就不会在高于浏览器HTML渲染表面而是与其他元素一样在同一个页面上,因此你就可以使用z-index值来控制DHTML元素是遮盖flash或者被遮盖。Transparent 模式透明模式,在这种模式下flash player会将stage的背景色alpha值将为0并且只会绘制stage上真实可见的对象,同样你也可以使用z-index来控制flash影片的深度值,但是与Opaque模式不同的是这样做会降低flash影片的回放效果,而且在9.0.115之前的flash player版本设置wmode=”opaque”或”transparent”会导致全屏模式失效。了解了各种模式的实现方式和意义在以后的开发中就可以按照具体情况选择设置wmode属性的值了。

网页中嵌入flash文件的几种方法相关推荐

  1. 网页中嵌入外部页面的四种方法

    一.应用框架技术  ---- 要在宿主页面中嵌入外部页面的方法是,在宿主页面中包含外部页面的位置插入"< IFRAME name="XXX" width=X hei ...

  2. flash 嵌入html代码,flash嵌入html在html网页代码中嵌入Flash文件的解决方案(下).doc...

    flash嵌入html在html网页代码中嵌入Flash文件的解决方案(下).doc flash嵌入 在 网页代码中嵌入Flash文件的解决方案(下) 在 代码中嵌入Flash文件一直都是广大web爱 ...

  3. 网页中嵌入flash的最佳方案

    http://solomon.athost.net/?p=549 网页中嵌入flash的最佳方案 各种浏览器差异悬殊,开发者应如何在网页中嵌入flash才是最佳方案?本文介绍的原理亦被应用在swfob ...

  4. Linux系统中运行.sh文件的几种方法

    在Linux系统中执行.sh文件的几种方法: 1. cd到.sh文件所在的目录,然后执行./xxx.sh   [前提:该./sh文件要有可执行的权限,chmod u+x xxx.sh]  2. 在任何 ...

  5. matlab中读文件的行数_Matlab中读取txt文件的几种方法

    Matlab中读取txt文件的几种方法 一.纯数据文件(没有字母和中文,纯数字) 对于这种txt文档,从matalb中读取就简单多了 例如test.txt文件,内容为"17.901 -1.1 ...

  6. matlab中如何读写txt,Matlab中读取txt文件的几种方法

    Matlab中读取txt文件的几种方法 matlab读取文本文件的几种函数: 1.load--适合读取纯数据文本: 2.importdata--只读取数据,自动省略数据格式前后的字符,超大文件不适合: ...

  7. 网页中嵌入Flash播放器

    1. 需要准备swfobject.js和flvplayer.swf文件,请看附件 2. flvplayer.swf有两种播放形式,一种是播放单个文件,一种是选择列表中的文件进行播放 a. 播放单个文件 ...

  8. 网页中嵌入Flash的方法讨论

    Flash 嵌入的问题论坛中有人问了好多次,到底应该怎么用,为什么通不过验证,要通过验证怎么办等等等. 讨论中也出现了不少的误解,所以我单开一个帖总结一下我所知道的东西,不想看我罗嗦的直接跳到最后看结 ...

  9. 网页中嵌入Flash的方法

    Flash 嵌入的问题论坛中有人问了好多次,到底应该怎么用,为什么通不过验证,要通过验证怎么办等等等. 讨论中也出现了不少的误解,所以我单开一个帖总结一下我所知道的东西,不想看我罗嗦的直接跳到最后看结 ...

  10. 网页中嵌入 Flash 的方法 满足W3C

    < DOCTYPE html PUBLIC -WCDTD XHTML TransitionalEN httpwwwworgTRxhtmlDTDxhtml-transitionaldtd> ...

最新文章

  1. 收集了7000个地震回波后,机器学习发现了地下上千公里处的热岩床
  2. 【SAP技术】SAP MM 如何看一个自定义移动类型是复制哪个标准移动类型而创建的?
  3. 干货丨机器学习研究者必知的八个神经网络架构(经典文章,值得收藏)
  4. 根据输入的日期计算你活了多少天(新手)
  5. SQLite Expert Pro中文版
  6. 【新品发布】山海软件生产线pspl,包含了一个开源的混淆器
  7. AS 3.0小事件处理 八
  8. Linux中内联函数,Windows 7上的内联函数的doParallel问题(适用于Linux)
  9. 新手须知,前端该如何与后端合作?
  10. 桃李春风一杯酒,江湖夜雨十年灯
  11. Flask 发布 1.0 稳定版
  12. [翻译]XNA 3.0 Game Programming Recipes之forty-seven
  13. 解决UE4官方文档C++API查询慢问题
  14. 最新版的Python写春联,支持行书隶书楷书,不再有缺失汉字
  15. 算法导论第三版 第一章答案
  16. tl wn322g linux驱动下载,tplink wn322g+驱动官方下载
  17. 版权声明--关于本人BLOG发表的带有原创标识的文章相关
  18. GEE引擎自定义进度条和自定义属性的脚本展示
  19. C++ char和uchar区别
  20. tonybot 人形机器人 首次开机 0630

热门文章

  1. 十、线程(11 章)
  2. 计算机技术比武通讯报道,第十六届后勤优质服务月:各部门积极开展技能比武,强化岗位技能,提升服务水平...
  3. python排版_Python|图形排版
  4. 12306抢票工具震撼来袭
  5. python-pygame实现飞机大战-4-获取补给、发射强化子弹以及放大招清屏
  6. 解决:Establishing SSL connection without server‘s identity verification is not recommended警告
  7. 华中农业计算机硕士就业,华中农业大学好就业吗?附华中农业大学就业率最高的专业名单...
  8. Music decoding tool | 音乐解码工具
  9. c语言程序设计大赛 作品,撒花 | C语言程序设计大赛、数据结构大赛圆满成功!...
  10. Xenu Link Sleuth 简单好用的链接测试工具 使用说明