如何处理不支持HTML5 / CSS3的浏览器(How to handle the browsers who don't support HTML5/CSS3)

编程入门 行业动态 更新时间:2024-10-17 02:53:32
如何处理不支持HTML5 / CSS3的浏览器(How to handle the browsers who don't support HTML5/CSS3)

我一直在研究HTML5和CSS3,并且一直很喜欢它。 绕过了modernizr API,但我陷入了困境,这导致了进一步的混淆:

如何编写适合浏览器之间不兼容情况的代码?

这导致以下混淆:

如果我将doctype写为<!DOCTYPE HTML>并且在IE6中访问我的页面,那么IE6将处理该页面吗? 如果我尝试包含<video>标签并且IE6 / IE7IE8(不支持此标签)再次访问该页面,那么我应该如何回滚闪存呢? 我应该使用一些JS来适当地显示/隐藏内容吗?

我很想听听你们的一些想法。 如果需要,请将此帖子标记为社区维基。

谢谢!

I have been looking into HTML5 and CSS3 and have been liking it quite a lot. Got around the modernizr API, but am stuck at one point, and that leads to further confusions:

How will I write a code that caters to the situation of non-compatibility between browsers ?

This leads to the following confusions:

if I write the doctype as <!DOCTYPE HTML> and my page is accessed in IE6, then ho IE6 will handle the page? If I try to include <video> tag and the page is again accessed by IE6/IE7IE8 (which don't support this tag), Then how am I supposed to be rolling back to flash for them? Should I use some JS to show/hide the content appropriately?

I would love to hear some thoughts of you guys. If needed, please mark this post as a community wiki.

Thanks!

最满意答案

要直接回答你的问题,

您必须意识到新的<!DOCTYPE HTML> doctype仅用于在浏览器中触发标准兼容模式。 传统上,从浏览器的角度来看,这个(称为doctype切换)是doctype用于唯一的东西。 因此,简而言之,如果您使用的是已触发标准模式的doctype,则IE6不会发生任何变化。

您可以使用Modernizr之类的脚本进行特征检测。 这将允许您仅在需要时使用Flash作为后备,并向支持它们的浏览器提供正确类型的电影。 即使您不使用该脚本,您仍然可以查看其来源以了解如何完成此操作。

或者, <video>和<audio>标签专门允许将后备内容嵌入其中。 这意味着您只需使用<video>标记包装Flash内容,如果浏览器不支持它们,则只需使用后备内容即可。

To answer your question directly,

You have to realize that the new <!DOCTYPE HTML> doctype is only used to trigger standard compliant mode in browsers. Traditionally, this (known as doctype switching) is the only thing the doctype is used for from the browser's perspective. So in short, nothing will happen change with respect to IE6 if you are using a doctype that already trigger standard mode.

You can use a script like Modernizr to do feature detection. This will allow you to use Flash as a fallback only in cases when its needed, as well as serve up the correct type of movie to browsers that support them. Even if you do not use the script, you can still look at its source to learn how this is done.

Alternatively, the <video> and <audio> tag specifically allow for fallback content to be embedded within them. This will means that you can simply wrap your Flash content with <video> tags, and if the browser does not support them it will simply use the fallback content.

更多推荐

IE,If,JS,电脑培训,计算机培训,IT培训"/> <meta name="description" co

本文发布于:2023-07-22 09:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219119.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不支持   如何处理   浏览器   browsers   handle

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!