コメント:ブラウザがキャンバスをサポートするかどうかを判断するためのいくつかの使用方法を収集して整理しました。興味のある友達はそれについて学ぶことができます。
ブラウザがキャンバスをサポートするかどうかを判断するために、特定のコードは次のとおりです。<!doctype html>
<head>
<メタcharset = utf-8 />
<title> canvas </title>
<script type = 'text/javascript'>
window.onload = function(){
/**ブラウザがキャンバスをサポートするかどうかを判断するだけです**/
試す{
document.createelement( 'canvas')。getContext( '2d');
var adddiv = document.createelement( 'div');
adddiv.innerhtml = 'canvas supported';
document.body.appendChild(addDiv);
} catch(e){
var adddiv = document.createelement( 'div');
adddiv.innerhtml = 'ブラウザはキャンバスをサポートしていません';
document.body.appendChild(addDiv);
}
};
</script>
</head>
<body>
</body>
</html>