
可以通过JS的方式测试
<script>window.onload = function() {
if (window.applicationCache) {
} else {
alert("你的浏览器不支持HTML5")
}
}
</script>
以上资料来源网络,或者访问相关的H5兼容性测试网站进行在线测试,如html5test等
利用HTML5新标签对象的方法来进行检测,比如Canvas对象的getContext()、Video对象的canPlayType等。如果浏览器支持HTML5,则返回相应的期望值(返回函数体,布尔值为true),否则无法获得期望值(返回undefined,布尔值为false)。
Canvas对象的getContext
// 方法一/**
* [supportHtml5 言成科技&HTML5学堂]
* @return {[type]} [description]
*/
function supportCanvas() {
return (typeof document.createElement('canvas').getContext === "function")
}
console.log(supportCanvas())
Video对象的canPlayType
// 方法二/*
* [supportsVideo 言成科技&HTML5学堂]
* @return {[type]} [description]
*/
function supportVideo() {
return !!document.createElement('video').canPlayType
}
console.log(supportVideo())
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)