判斷瀏覽器是否支持canvas,具體代碼如下: 複製代碼代碼如下: canvas <br />window.onload = function(){ <br />/**判斷瀏覽器是否支援canvas**/ <br />try{ <br />document.createElement('canvas').getContext('2d'); <br />var addDiv = document.createElement('div'); <br />addDiv.innerHTML='支援canvas'; <br />document.body.appendChild(addDiv); <br />}catch(e){ <br />var addDiv = document .createElement('div'); <br />addDiv.innerHTML='瀏覽器不支援canvas'; <br />document.body.appendChild(addDiv); <br />} <br />}; <br />