Related Posts

Archive

SVG detection without VBScript

December 16th, 2005

V.3 of the Adobe SVG Viewer for Internet Explorer likes the EMBED tag. Jeff Schiller pointed out V.6 should/does support OBJECT. Everybody else likes OBJECT, if anything at all.

I’ve seen a Adobe-Sanctioned detect for their plugin. It uses both VBScript and Javascript. Stupid VBScript.

Taking a hint from AJAX detects, I have made a Javascript-only detect, that returns the tag to use if anything is supported.

Test: /projects/DetectSVG.html

<script type="text/javascript">
function checkSVG ( ) {
if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) {
if (navigator.mimeTypes["image/svg+xml"] != null) { return “object”; }
}
else if (window.ActiveXObject) { // Adobe plugin
try { adobe = new ActiveXObject(”Adobe.SVGCtl”); return “embed”; }
catch (e) { return “MS Error”; }
}
return “none”;
}
</script>

Ideally, I’d like to make a list of which combonations get which responces. What I have so far (and they all work):

IE6+ASV3 - embed
Firefox 1.5 - object
Safari 1.3.1 - object
Opera 7.54 - object

Posted in JavaScript |

2 Responses to “SVG detection without VBScript”

  1. Kae Verens Says:

    maybe it’s just Linux, but my Firefox 1.5 claims not to have SVG capability (which it does have) using your script. This is because the only occupant of its mimeTypes array is “*”, which is unhelpful…

  2. Modern script-based SVG detection Says:

    [...] SVG 1.2 plugin. It’s not quite ready, but it’s quickly getting there. As pointed out on GR[ae]YSCALE, you don’t need VBScript to check for plugin support. Their script is nice, and here is my [...]

Previous post: freeTime++

Next Post: IE6 brokenness