Using JavaScript, is it possible to obtain a list of the tags that a browser supports?
If you're willing to start with a known list of candidate tags, you could try something like this:
document.createElement("asdf") instanceof HTMLUnknownElement
true
document.createElement("canvas") instanceof HTMLUnknownElement
false
If you need to support IE8, you could use this approach:
function browserSupports(elementTagName) {
var el = document.createElement(elementTagName);
return !((el instanceOf HTMLUnknownElement) || (el instanceof HTMLGenericElement));
}
Here's another approach that doesn't rely on specific named constructors.
function browserSupports(elementTagName) {
var unknownel = document.createElement("zzxcv");
var el = document.createElement(elementTagName);
return unknownel.constructor !== el.constructor;
}
It still doesn't seem to work in IE8 though.