Check canvas support?

A

Asen Bozhilov

How you check client browser for support of canvas element from HTML5.
Here i don't want to check user agent or creating dummy canvas element
or anything else in this styling.
In code.google i found one `object' canvas_support:
<URL:http://code.google.com/p/browser-canvas-support/wiki/
BrowserCanvasSupport>
I don't like this. In HTML5 working draft is defined DOM Interface
`HTMLCanvasElement', who's associated with global execution context.
After that:

var Canvas = {
isSupported : Boolean(this.HTMLCanvasElement)
}

How you thinking about check for canvas supported?

Thanks for responses.
 
J

Jorge

How you check client browser for support of canvas element from HTML5.
Here i don't want to check user agent or creating dummy canvas element
or anything else in this styling.

Why not ? e.g.:

if (document.createElement('canvas').getContext) {
//ok
} else {
//not ok
}
In code.google i found one `object' canvas_support:
<URL:http://code.google.com/p/browser-canvas-support/wiki/
BrowserCanvasSupport>
I don't like this. In HTML5 working draft is defined DOM Interface
`HTMLCanvasElement', who's associated with global execution context.
After that:

var Canvas = {
  isSupported : Boolean(this.HTMLCanvasElement)

}

How you thinking about check for canvas supported?

Thanks for responses.

You're welcome,
 
R

RobG

How you check client browser for support of canvas element from HTML5.
Here i don't want to check user agent or creating dummy canvas element
or anything else in this styling.
In code.google i found one `object' canvas_support:
<URL:http://code.google.com/p/browser-canvas-support/wiki/
BrowserCanvasSupport>
I don't like this. In HTML5 working draft is defined DOM Interface
`HTMLCanvasElement', who's associated with global execution context.
After that:

var Canvas = {
  isSupported : Boolean(this.HTMLCanvasElement)

}

How you thinking about check for canvas supported?

I played with canvas a little while ago and created a Canvas
constructor so I could have a number of them in the page. Testing for
element.getContext was sufficient on the limited number of browsers I
was interested in. I can't say if it's suitable for general use:

if (element.getContext) {
this.context = element.getContext('2d');
} else {
alert('Context not supported');
return;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top