The standard way to deal with situations where the browser does not support the HTML5 <canvas>
tag is to embed some fallback content like:
<canvas>Your browser doesn't support "canvas".</canvas>
But the rest of the page remains the same, which may be inappropriate or misleading. I'd like some way of detecting canvas non-support so that I can present the rest of my page accordingly. What would you recommend?
You can use canisuse.js script to detect if your browsers supports canvas or not
Why not try modernizr ? It's a JS library that provides detection capability.
Quote:
There may be a gotcha here- some clients do not support all canvas methods.
This is the technique used in Modernizr and basically every other library that does canvas work:
Since your question was for detection when it's not supported, I recommend using it like so:
I usually run a check for
getContext
when I create my canvas object.If it is supported, then you can continue the canvas setup and add it to the DOM. This is a simple example of Progressive Enhancement, which I (personally) prefer over Graceful Degradation.