Home > Web Front-end > JS Tutorial > js determines whether the browser supports html5_javascript techniques

js determines whether the browser supports html5_javascript techniques

WBOY
Release: 2016-05-16 16:39:29
Original
1644 people have browsed it

Now HTML5 seems to be slowly becoming popular. For the sake of compatibility, some front-end experts will add code to judge the client browser in the web page to know whether the user's browser supports HTML5. Below I will share two methods that I use myself. Method

Method 1,

<script>  
function checkhHtml5() {   
if (typeof(Worker) !== "undefined") {   alert("支持HTML5");   }   else {   alert("不支持HTML5");   }  } 
</script>
Copy after login

Method 2,

<canvas id="Canvas" ></canvas>

<script>   if (!document.getElementById("Canvas").getContext) {     alert("不支持html5");   }   else{  alert("支持html5");  } </script>
Copy after login

If there is a better way, please contact me! Thank you

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template