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.