Skip past introduction.

WolfBlog

Reflections from a Swede in Norway.

Here you will find my small graffiti board where I write about things I come to think about.

In my blog, I write about the general unfairness of life, about spam mail, vintage computers, board games, Norwegians, current and not-so-current affairs, technology and whatever else occurs to me — in other words, a glorious mess. All opinion expressed here are of course my own, and all similarities with any living people is of course intentional.

These pages are using automatic language selection, if you prefer to read in Swedish, please use this page instead. See the help for info on how to make your web browser select the correct language automatically. A monthly overview is also available.

All text and pictures copyright Peter Krefting, unless otherwise noted. More about the author.

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:

Categories: Internet, software. Share: Facebook, Google+, email

| | Latest postings | This month | All months and categories

This page is best read on the Internet.

[Bloggportalen]

peter@softwolves.pp.se