javascript: How to detect SVG in HTML-img support?
I tried this, but it does not work:
x = new Image(); x.onload = function(){ if (x.width) { alert('svg in img tag supported!'); } }; x.src = 'test.svg';
A good discussion / comparison of methods is here: http://www.voormedia.nl/blog/2012/10/displaying-and-detecting-support-for-svg-images
Based on this page, I ended up using this:
svgsupport = document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")
Use modernizr to detect such a function.
if (Modernizr.SVG){ //svg supported }