判斷浏覽器是否支持canvas,具體代碼如下:
復制代碼代碼如下:
www.mb5u.com
<!DOCTYPE Html>
<head>
<meta charset=utf-8 />
<title>canvas</title>
<script type='text/Javascript'>
window.onload = function(){
/**判斷浏覽器是否支持canvas**/
try{
document.createElement('canvas').getContext('2d');
var addDiv = document.createElement('div');
addDiv.innerHtml='支持canvas';
document.body.appendChild(addDiv);
}catch(e){
var addDiv = document.createElement('div');
addDiv.innerHtml='浏覽器不支持canvas';
document.body.appendChild(addDiv);
}
};
</script>
</head>
<body>
</body>
</Html>