How to handle the browsers who don't support HTML5/CSS3
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!
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.
Three things you need:
1. Check the list of supported features.
2. Detect HTML5 features
3. Use Graceful Degradation
精彩评论