What to use to test whether the browser supports HTML5-PHP Chinese website Q&A-What to use to test whether the browser supports HTML5-PHP Chinese website Q&A
<!DOCTYPE>
<html>
<head>
<meta charset="gbk"/>
<title>测试浏览器是否支持HTML5</title>
<script language="javascript">
function test() {
try{
document.createElement("canvas").getContext("2d");
document.getElementById("support").innerHTML="HTML5 Canvas is supported in your browser";
}catch(e){
document.getElementById("support").innerHTML="HTML5 Canvas is not supported in your browser";
}
}
</script>
</head>
<body onLoad="test()">
<p id="support"></p>
</body>
</html>
What to use to test whether the browser supports HTML5-PHP Chinese website Q&A-What to use to test whether the browser supports HTML5-PHP Chinese website Q&A
Just watch and learn.
可以通过以下方法, 测试浏览器是否支持HTML5:
创建一个test.html文件
上面的代码试图创建一个canvas 对象,并且获取上下文,如果发生异常,则可以捕获错误,判断是否支持HTML5