Is that all the major browser vendors have implemented support for
the canvas element. This means that you can be relatively confident that your user can see the animation
you create, provided she has upgraded to a recent version of her browser. Games and animations provide
an excellent way to push users into upgrading their browsers, because, after decades of video games,
most people understand that cutting-edge graphics require the latest hardware and software. At least it’s
easier to convince someone to upgrade her browser rather than buy a brand new gaming console.
In case the canvas element is not supported in a web browser, in your HTML document, you can provide
backup content by including it within the canvas tags:
<canvas width="400" height="400">
<p>This browser does not support the<code>canvas</code> element.</p>
</canvas>
The warning message appears only if the browser does not recognize the canvas tag. If the browser does
support it, then it renders the canvas element and ignores the nested <p> element.
To programmatically test whether the browser supports the canvas element, you can add the following
JavaScript to your document:
if (document.createElement('canvas').getContext) {
console.log("Success! The canvas element is supported.");
}
This code creates a new canvas element and tests for the existence of its getContext property, which the
object has if it's a valid HTML5 canvas element. If the browser does have support, it prints a message to
the debugging console letting you know.
IE Firefox Safari Chrome Opera iOS Safari Android Browser
9 3.5 3. 2 9 10.6 3. 2 2. 1
0 comments:
Post a Comment