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.

Object.toString on MDN

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Comments

You can leave a response, or trackback from your own site.

Before you add comment see for rules.

Leave a Reply

Your email address will not be published. Required fields are marked *

9c7h2o