How can I tell if a javascript object is an Image or a Canvas?
function isCanvas(i) {
return i instanceof HTMLCanvasElement;
}
If cross-window/frame compatibility is a concern you can check nodeName
:
var isImg = (element.nodeName.toLowerCase() === 'img');
function isImage(i) {
return i instanceof HTMLImageElement;
}