mike chambers | about

Determining whether your extension is running in FireFox or Thunderbird

Thursday, December 9, 2004

One of the things that is cool about building extensions for FireFox, is that in most cases they can easily made to run within Thunderbird. However, sometimes your extension needs to know which environment it is running within. You can determine this by checking the navigator.vendor property.

var firefox = false;
var thunderbird = false;

var vendor = navigator.vendor;

if(vendor == "FireFox")
{
    firefox = true;
}
else if(vendor == "Thunderbird")
{
    thunderbird = true;
}

dump("Running in FireFox : " + firefox + "\n");
dump("Running in Thunderbird : " + thunderbird + "\n");

This makes it easy to branch your code when necessary.

twitter github flickr behance