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

js determines whether the browser supports html5_javascript techniques

WBOY
WBOYOriginal
2016-05-16 16:39:291566browse

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>

Method 2,

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

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

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

Statement:
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