有没有一种标准的复制粘贴方式来安全地将SWF放入网页中? [英] Is there a standard copy-paste way to safely put a SWF in a web-page?

查看:153
本文介绍了有没有一种标准的复制粘贴方式来安全地将SWF放入网页中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然在HTML中嵌入SWF并不难,但是对于不同的浏览器来说,有一些微妙之处,检测是否安装了Flash。
为了启用AJAX,可以使用标准的代码块来保存处理所有情况的麻烦...是他们的一个类似的参考实现来嵌入一个SWF,它涵盖了所有的基础?

解决方案

有没有标准?不幸的是 。 Flash嵌入方法的要点如下:


  1. 现代浏览器兼容

  2. li>
  3. 古代浏览器兼容

  4. 符合标准

  5. 支持流式Flash(在整个文件下载之前播放) IE

  6. 不重复自己

  7. 允许后备内容

  8. 无JavaScript依赖

但是没有一组标记符合所有这些要点。第6点是不可能完全实现的,但有些解决方案比其他解决方案更糟。关于最简单的标记,你可以得到的是经典的 Flash Satay 文章:

 < object type =application / x-shockwave-flashdata =file.swfwidth =xheight =y> 
< param name =movievalue =file.swf/>
(非Flash内容)
< / object>

ALA文章抱怨说,如果不是这个版本的话,这个版本不会提示用户下载Flash安装;我个人认为这是一个加点。但是在第三点和第五点仍然失败。第五点可能并不重要:如果你的Flash文件是一个简单的应用程序,媒体播放器或者加载程序存根根本就不重要,但是如果它是一个大的动画,它可能是不幸的。

也许点3不再重要;没有人真的使用Netscape 4或IE4这些天。但如果它对你有用,你需要老式的嵌入式标签。这也是现代浏览器所支持的,这意味着你可以使用外部对象的ActiveX方法,所以你可以在IE浏览器中进行流式处理:

 < object classid =clsid:D27CDB6E-AE6D-11cf-96B8-444553540000width =xheight =y> 
< param name =movievalue =file.swf/>
< embed type =application / x-shockwave-flashsrc =file.swfwidth =xheight =y/>
< / object>

这是嵌入Flash的传统方法。它在第四点和第七点都失败了,在第六点也稍微差一些。

第三种方法,被库使用,比如 SWFObject 是使用JavaScript来选择在当前浏览器上实例化Flash的最佳方式。这可以达到上述所有要点,除了自然地,8.有些图书馆通过还包括静态对象标记,第6点的交易点8,提供了减轻这种情况的方法。


While embedding a SWF in HTML is not too hard, there are a few subtleties for different browsers, detecting if Flash is installed, etc. For enabling AJAX, there are standard chunks of code you can use to save the hassle of coping with all cases... is their a similar 'reference implementation' to embed a SWF which covers all the bases?

解决方案

Is there a standard? Sadly no. The desirable points of a Flash embedding method are:

  1. modern browser compatible
  2. IE compatible
  3. ancient browser compatible
  4. standards-compliant
  5. supporting streamed Flash (play before the whole file is downloaded) in IE
  6. Don't Repeat Yourself
  7. allow fallback content
  8. no JavaScript reliance

but there is no one bunch of markup that satisfies all these points. Point 6 is impossible to achieve fully but some solutions fail worse than others.

About the simplest markup you can get away with is the version outlined in the classic Flash Satay article:

<object type="application/x-shockwave-flash" data="file.swf" width="x" height="y">
    <param name="movie" value="file.swf" />
    (Non-Flash content here)
</object>

The ALA article complains that this version won't prompt the user to download Flash if it isn't installed; personally I see this as a plus point. But it still fails on points 3 and 5. Point 5 may or may not matter: if your Flash file is a simple application, media player or loader stub it doesn't matter at all, but if it's a big animation it can be unfortunate.

Maybe point 3 doesn't matter any more; no-one's really using Netscape 4 or IE4 these days. But if it does to you, you need the old-school embed tag. This is also supported by modern browsers so that means you can use the ActiveX method for the outer object, so you get streaming in IE:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="x" height="y">
    <param name="movie" value="file.swf" />
    <embed type="application/x-shockwave-flash" src="file.swf" width="x" height="y" />
</object>

This is the ‘traditional’ method of embedding Flash. It fails on points 4 and 7 and is slightly worse on point 6.

The third approach, used by libraries such as SWFObject is to use JavaScript to choose the best way to instantiate Flash on the current browser. This can hit the all the above points except, naturally, 8. Some libraries offer ways to mitigate that by also including static object markup, trading point 8 for point 6.

这篇关于有没有一种标准的复制粘贴方式来安全地将SWF放入网页中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆