Detecting Adobe’s plug-in for SVG in Internet Explorer
Published: Saturday 2005-11-26.
After I re-did my logotype in SVG I of course wanted as many as possible to see it in that format. Earlier I used a transparent PNG image as logotype, something Internet Explorer has severe problems with. Since I (unfortunately) have several visitors running Internet Explorer I implemented a hack to work around the limitations of this web browser, I wrote a script that rewrote the HTML code of the page in such a way that IE was able to display the transparent image.
The problem was now that after I had added support for SVG the code was still rewritten, and IE did not get the new logotype. I thus decided to disable the code if Adobe’s plug-in for SVG had been installed, but all the examples I found on the web used a VBScript hack that gave me problems when I tried to add it to my existing framework. After some thinking I, however, came up with a simple and elegant solution:
var p;
try {
p = new ActiveXObject("Adobe.SVGCtl");
}
catch (e) {
document.write("<p>Plug-in for SVG has not been installed (or you are not running IE).</p>");
}
if (p)
{
document.write("<p>Plug-in for SVG has been installed.</p>");
}
This works fine, and now even IE users get the SVG version of my logotype if the plug-in has been installed. This is what the script says about your web browser:
