HTML5 Mobile Development (mobile device detection and support for HTML5)

Source: Internet
Author: User

1. How to select the features you want to use and the browser you are targeting2. Which browsers support HTML53. How to detect if HTML5 is supported4. How to develop a loan-tolerant Web application5.CSS3 Media Query How to enhance a detection script when using frontier predictions such as HTML5, you might choose the following two scenariosI. As close to the new standards as possible, ignoring those platforms that are not supportedtwo. Do not use any new technology, know that the change standard is widely supported by browser system. now we're going to use the third approach: the sensible trade-offs of new technologies and the careful handling of compatibility issues, so that you can open up Web applications that are reliable and useful to most users.  There are 4 basic methods for detecting HTML5 functions:I. Detecting properties on a global objecttwo. Detecting attributes on created elementsThree. Detect if a methed can get the correct return valueFour. Detect if element values can be preserved detecting attributes with global elementsall HTML5 documents are displayed in a global element, which is often referred to as Navigator or window.You can create some HTML5 properties directly on these global properties. In this case, the browser can use them directly. as follows:if (window.applicationcache) {document.write ("Yes,your Borwser can use offline Web application");} else {document.write ("No,your Borwser cannot use offline Web application");}if the browser supports offline Web, then you can use it normally, otherwise ....  detect attributes with the elements created not really creating elements, you just create a dummy element in the browser memory. It will help you to complete the inspection, and will not appear in the browser. This is also a necessary test because any element can be added to the DOM, but when the added element cannot be recognized by the browser, the browser adds a standard global attribute to it and essentially ignores it. If reign title is recognized by the browser, the browser will add a proprietary attribute to it. For example:if (document.createelement (' canvas '). GetContext) {document.write (' Yse,your borwser can use the canvas ');} else {document.write ("No,your Borwser cannot use the canvas");} whether the detection method can return the correct valueas follows:return!! Document.createelement (' video '). Canplaytype;if supported, then test the H.!! Video.canplaytype (' Video/mp4; codecs= "avc1.42e01e, mp4a.40.2" ') write it all down to:function Videocheck () {Retrun!! Document.createelement (' video '). Canplaytype;}function H264check () {if (!videocheck) {Document.witet ("not");return;    }var video = document.createelement ("video");if (!video.canplaytype (' Video/mp4; codecs= "avc1.42e01e, mp4a.40.2" ')) {Document.witet ("not");    }return;} detects whether an element retains a valuedetecting whether an element retains related values is the most complex of the detection methods. You first need to create a dummy element, then detect the specified method, and finally detect whether the value of the method is retained as expected. as follows:var i = document.createelement ("input");i.setattrbute ("type", "range");if (I.type = = "Text") {document.write ("not");} handling Ie7, Ie7, Ie6<!--[if Lt IE 9]><script src= "Http://html5shiv.googlecode.com/svn/trunk/html5.js" ></script><! [endif]-->add this. Although the low version of IE can recognize HTML5 new tags, it still does not support the corresponding features of the new tags.  Graceful Demotion: The system should continue to run when one or more of the components are wrong. In web development, this means that the Web page continues to run even when the HTML5 component cannot be fully supported by the browser.  using CSS media queries to detect mobile browsers<link media= "screen" rel= "stylesheet" href= "Style.css" ><style>@media print{//add style here  }</style>CSS3 expands the media properties so that users can detect user agents under various conditions. The browser can output the corresponding style sheet if the condition is met. as follows:<link rel= "stylesheet" media= "screen and (max-width:128px)" href= "Small-srceen.css" >  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.