Categories
JavaScript Answers

How to detect support for VML or SVG in a browser with JavaScript?

Spread the love

Sometimes, we want to detect support for VML or SVG in a browser with JavaScript.

In this article, we’ll look at how to detect support for VML or SVG in a browser with JavaScript.

How to detect support for VML or SVG in a browser with JavaScript?

To detect support for VML or SVG in a browser with JavaScript, we can use the document.implementation.hasFeature method.

For instance, we write:

document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Shape", "1.0")

to detect SVG support in the browser.

If it returns true, then it’s supported.

Conclusion

To detect support for VML or SVG in a browser with JavaScript, we can use the document.implementation.hasFeature method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

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