admin管理员组文章数量:1318569
I have written a Firefox extension and am currently in the process of updating it for Firefox 4 and adding some new features.
Firefox 4 has a great new notification display that I'd quite like to use and have found plenty of documentation on how to use it. However, for anything less than 4 I have created my own notification window with specific styles.
My question is: how can I detect whether I'm using Firefox 4 or not in the javascript for my extension. Or, is there a better way of doing this?
I have written a Firefox extension and am currently in the process of updating it for Firefox 4 and adding some new features.
Firefox 4 has a great new notification display that I'd quite like to use and have found plenty of documentation on how to use it. However, for anything less than 4 I have created my own notification window with specific styles.
My question is: how can I detect whether I'm using Firefox 4 or not in the javascript for my extension. Or, is there a better way of doing this?
Share Improve this question asked Feb 11, 2011 at 9:19 AlexAlex 7,3741 gold badge20 silver badges31 bronze badges 1- 1 If you're referring to PopupNotifications.jsm then you can just look for the window.PopupNotifications variable and if it exists then you can use it otherwise you can use your own notification window. – Neil Commented Feb 11, 2011 at 23:59
2 Answers
Reset to default 10You can use nsIXULAppInfo
:
var appInfo = Components.classes["@mozilla/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo);
// appInfo.version contains the version
You can pare versions with nsIVersionComparator
.
Maybe there is a better way, but this definitely works for me.
Following links will give you some idea how to do it.
http://bytes./topic/javascript/answers/822435-how-can-i-get-firefox-version
http://www.quirksmode/js/detect.html
本文标签: javascriptGet Browser Version From Firefox ExtensionStack Overflow
版权声明:本文标题:javascript - Get Browser Version From Firefox Extension - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742047065a2417848.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论