使用动画 PNG 图像时避免浏览器不兼容
动画 PNG 图像 (APNG) 已经存在很长一段时间了,试图添加此功能将 GIF 格式转换为 PNG 图像。 根据维基百科,它们在 Opera (>= 9.5) 和 Firefox (>; 9.5) 中受支持。 = 3.0)。 如果浏览器不支持 APNG 图像,则会显示 APNG 动画中的第一帧,因为它被定义为广泛支持的 PNG 格式的扩展。 假设您有一个要在网站中显示的动画 PNG,并且您希望在用户的浏览器不支持它时向用户发出警告。 你会怎么做?
Animated PNG images (APNG) have been around for quite a while in an attempt to add this functionality of the GIF format to PNG images. According to Wikipedia they are supported in Opera (>= 9.5) and in Firefox (>= 3.0). The first frame in the APNG animation is displayed if a browser doesn't support APNG images, since it was defined as an extension of the widely supported PNG format. Suppose you have an animated PNG that you want to show in your site and you want to warn your users if their browsers doesn't support it. How would you do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让第一个图像显示的时间很短,并让它成为一个又大又难看的错误消息。
Make the first image display for a very short period of time, and have it be a big, ugly error message.
如果第一帧不是有用的图像,而动画至关重要,那么在您的网站中使用它们可能还为时过早。 最好等到更多浏览器支持它。
如果由于某种原因它们至关重要并且必须使用,那么我会在第一帧中包含一条错误消息,例如 Adam Jaskiewicz 建议时,支持 APNG 的用户将在短时间内看到该警告。
显然可以检测到支持,如这篇关于 Ajaxian 的文章
If the first frame isn't a useful image, and the animation is crucial, it's probably too early be using them in your website. Better to wait until more browsers support it.
If for some reason they're vital and must be used then I'd include an error message in the first frame like Adam Jaskiewicz suggested, however, users that support APNG will see the warning for a brief period of time.
Apparently support can be detected as in this article on Ajaxian