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

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

问题描述

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

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?

推荐答案

有标准吗?遗憾的是没有.Flash 嵌入方法的理想点是:

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

  1. 兼容现代浏览器
  2. IE 兼容
  3. 兼容古代浏览器
  4. 符合标准
  5. 在 IE 中支持流式 Flash(在下载整个文件之前播放)
  6. 不要重复自己
  7. 允许后备内容
  8. 不依赖 JavaScript

但是没有一堆标记可以满足所有这些要点.第 6 点不可能完全实现,但有些解决方案比其他解决方案失败得更糟.

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.

关于您可以摆脱的最简单的标记是经典Flash Satay 文章:

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>

ALA 文章抱怨此版本如果未安装 Flash,将不会提示用户下载;我个人认为这是一个加分点.但它仍然在第 3 点和第 5 点失败.第 5 点可能重要,也可能无关紧要:如果您的 Flash 文件是一个简单的应用程序、媒体播放器或加载程序存根,则根本不重要,但如果它是一个大动画,则可能很不幸.

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.

也许第 3 点不再重要;现在没有人真正使用 Netscape 4 或 IE4.但如果它对你有帮助,你需要老式的嵌入标签.现代浏览器也支持这一点,这意味着您可以对外部对象使用 ActiveX 方法,因此您可以在 IE 中进行流式传输:

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>

这是嵌入 Flash 的传统"方法.它在第 4 点和第 7 点失败,在第 6 点稍差.

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

SWFObject 等库使用的第三种方法是使用 JavaScript 来选择在当前浏览器上实例化 Flash 的最佳方式.这可以达到上述所有点,当然,除了 8.一些库提供了减轻这种情况的方法,方法是还包括静态对象标记,将点 8 换成点 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天全站免登陆