HTML5 Canvas Browser Support
HTML5 canvas API is supported by major browsers these days. Microsoft announced that IE 9 will support canvas as well. However, there are old browsers out there that don’t provide HTML5 canvas support and we need to handle these limitations for the users who use those old browsers.
In order to check if browser supports HTML5 canvas, we need to add the following line of code to our page.
try
{
document.createElement("canvas").getContext("2d");
document.getElementById("HTML5CanvasOK").innerHTML = "HTML5 canvas is supported.";
}
catch (exception)
{
document.getElementById("HTML5CanvasOK ").innerHTML = "Browser does not Support HTML5 canvas";
}
As you can see we use error handling in the example above where we simply try to use canvas and if failure occur, our error handler will catch error in the catch() error handling code. This is where we can handle error in a more graceful manner by notifying user that HTML5 is not supported on the browser they are currently using for your website viewing.