Re: Detecting SVG-in-HTML capabilities

Jeff Schiller wrote:
> Most browsers support inline SVG in XHTML (application/xhtml+xml).  No
> browsers natively support SVG-in-HTML (text/html) though Firefox
> sounds like it is getting closer.
> 
> Should there be a feature string defined in HTML5 for this capability
> (i.e. specifically for supporting SVG-in-HTML-syntax) for use with
> hasFeature [1]?  I'm concerned about fallback scenarios and for
> preventing extra work for some libraries [2].
> 
> Regards,
> Jeff
> 
> [1] http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-5CED94D7
> [2] http://berjon.com/hacks/force-svg/


I'm not sure we want to advocate use of hasFeature, as it seems better 
to check for capability rather than some claim to support.

Given an HTML-with-SVG document, you could just:

var svg = document.getElementsByTagName("svg")[0];
var supported = svg.namespaceURI == "http://www.w3.org/2000/svg";

-- 
Geoffrey Sneddon — Opera Software ASA
<http://gsnedders.com/>
<http://www.opera.com/>

Received on Thursday, 23 July 2009 09:22:15 UTC