Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Which program am I?

0 views
Skip to first unread message

Anthony Lieuallen

unread,
Nov 16, 2006, 12:49:47 AM11/16/06
to
I'm looking for a proper way to tell which application an extension,
compatible with more than one is running in.

Simply put, "Am I Firefox or Thunderbird?"

Soyapi Mumba

unread,
Nov 16, 2006, 2:03:10 AM11/16/06
to Anthony Lieuallen, dev-ext...@lists.mozilla.org
Anthony Lieuallen wrote:
> I'm looking for a proper way to tell which application an extension,
> compatible with more than one is running in.

Check the value of navigator.userAgent

This is what I use:

// -------------------
if (navigator.userAgent.search(/Thunderbird/gi) != -1) {
// Thunderbird specific code
} else {
// Firefox code
}
// ----------------

- Soyapi
--
Soyapi Mumba
soyapi.blogspot.com
searchwith.mozdev.org

Gijs Kruitbosch ("Hannibal")

unread,
Nov 16, 2006, 4:44:18 AM11/16/06
to Soyapi Mumba, Anthony Lieuallen, dev-ext...@lists.mozilla.org
Soyapi Mumba wrote:
> Anthony Lieuallen wrote:
>> I'm looking for a proper way to tell which application an extension,
>> compatible with more than one is running in.
>
> Check the value of navigator.userAgent
>
> This is what I use:
>
> // -------------------
> if (navigator.userAgent.search(/Thunderbird/gi) != -1) {
> // Thunderbird specific code
> } else {
> // Firefox code
> }
> // ----------------
>
> - Soyapi

Generally, if available, you should use nsIXULAppInfo for that.
See
http://bonsai.mozilla.org/cvsblame.cgi?file=mozilla/extensions/irc/xul/content/static.js&rev=1.215#412
for an example.

HTH,
Gijs

LouCypher

unread,
Nov 16, 2006, 7:04:36 AM11/16/06
to
http://developer.mozilla.org/en/docs/Using_nsIXULAppInfo

http://developer.mozilla.org/en/docs/Using_nsIXULAppInfo#ID
"Note: you could also use nsIXULAppInfo.name, which is a human-readable
name for the application, such as "Firefox", but who knows, maybe
they'll rename it again!"

Philip Chee

unread,
Nov 16, 2006, 9:23:09 AM11/16/06
to
On 16 Nov 2006 04:04:36 -0800, LouCypher wrote:

> http://developer.mozilla.org/en/docs/Using_nsIXULAppInfo

> http://developer.mozilla.org/en/docs/Using_nsIXULAppInfo#ID
> "Note: you could also use nsIXULAppInfo.name, which is a human-readable
> name for the application, such as "Firefox", but who knows, maybe
> they'll rename it again!"

Yeah. On Debian, Firefox is now known as IceWeasel for some obscure reason.

Phil

--
Philip Chee <phi...@aleytys.pc.my>, <phili...@gmail.com>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.

0 new messages