开发者

How do I determine if my addon is running in firefox or in fennec?

开发者 https://www.devze.com 2022-12-20 21:10 出处:网络
I am making an addon for both firefox and fennec and I want to know if it is running on fennec o开发者_如何转开发r not.The global Application object (provided by FUEL) will give you various properties

I am making an addon for both firefox and fennec and I want to know if it is running on fennec o开发者_如何转开发r not.


The global Application object (provided by FUEL) will give you various properties such as name or id that you can use to determine this.


What sdwilsh said or using nsIXULAppInfo.

If Fennec does support FUEL (I haven't checked), it's a matter of personal preference which one to use. FUEL is supposed to be a simpler-to-use wrapper around the nsI* components.


You could use document.getElementById("browsers"). In firefox, it's null but in fennec it returns a HTMLDivElement object


In the current version of the extensions API, the xul-app module exposes a name property which is set to either Firefox or Fennec. This seems to work nicely.

var xul_app = require('xul-app');
var isMobile = (xul_app.name.toLowerCase().indexOf('fennec') > -1);
0

精彩评论

暂无评论...
验证码 换一张
取 消