To check if browser support specified HTML element you can use:
function isHTMLElementSupported(elm) {
return (Object.prototype.toString.call(document.createElement(elm)) !== '[object HTMLUnknownElement]');
};
Object.prototype.toString
returns the value of the object’s internal [[Class]]
property.
Every object has a toString() method that is automatically called when the object is to be represented as a text value or when an object is referred to in a manner in which a string is expected. By default, the toString() method is inherited by every object descended from Object. If this method is not overridden in a custom object, toString() returns “[object type]”, where type is the object type.
Leave a Reply