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.  

Featured pages

Overview

Learn about HTML5 architecture, design principles and patterns on HTML5 Overview Tutorial. Become …

Tags

Learn about HTML5 tags and discover a new list of HTML5 tags. Find out about HTML5 tags support by…

Welcome

 Learn HTML5 development techniques, tips and tricks on our website. Find out what is required…

Date Time Picker

HTML5 forms use date and time controls regularly. HTML5 date and time controls are used by booking …