Enrico Foschi’s official blog

Something about me – .NET Team Leader with an entrepreneurial mind

Archive for the ‘agglom’ Category

How to check with Javascript if a Firefox Add-on / Extension is installed

with 10 comments

Agglom was used to display an invitation to download the Firefox Add-on Agglomerator in the main pages to all the users.

Unfortunately, the invitation was displayed by users that already installed the Add-on too. The challenge was to check with JS if the user already had the add-on installed and, if he had it, to hide the invitation.

Surfing the web I stumbled upon this page:
http://ha.ckers.org/weird/firefox-extentions.html

Thanks to ha.ckers.org, the feature has been pretty easy to develop. What we did was to include the invitation inside a DIV with a specified id (firefoxExtension). Right after the closing tag of the DIV we appended this image:

<img src=”chrome://agglomerator/skin/icon24.png”
class=”displayNone”
onload=”if(document.getElementById(‘firefoxExtension’))
document.getElementById(‘firefoxExtension’).style.display=’none’;” />

The IMG tag loads an image that is included in Agglomerator (the icon displayed in the toolbar to save and share the current browser session). If the extension has been installed correctly, the icon will be loaded and the onload event will be fired. This is then hiding the DIV with id=firefoxExtension. If the extension is not installed, the onload event won’t be fired.

This is a quick and dirty method and should work with all almost any add-on.

Hope it helps.

Written by Enrico Foschi

August 21, 2008 at 9:14 pm