Get Browser Version From Firefox Extension - javascript

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?

You can use nsIXULAppInfo:
var appInfo = Components.classes["#mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo);
// appInfo.version contains the version
You can compare 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.com/topic/javascript/answers/822435-how-can-i-get-firefox-version
http://www.quirksmode.org/js/detect.html

Related

Find specific IE11 version with Javascript?

I've read a few threads on this, but I didn't get a reply: is it possible to detect the specific IE11 version? For example, the version of my IE is 11.420.10586.0. Is there a way to get all this using Javascript?
I'm currently using Polymer to build a webapp and I found that there is a specific problem that only occurs on IE 11.0.9600.17420 and lower, but newer versions are not affected by this problem and I was trying to show a message to the user saying they need to update the browser.

Detect browser type and version in AngularJS and display a message if is not supported

I need to detect the browser type and version from where a Angular app is being accessed. I know there are a few JS libraries out there but don't know which one to use.
The web app is supposed to be supported on the latest editions of Chrome, Safari, Firefox, and Internet Explorer.
I've found this answer but I don't know if is the right way to go, so any advice around this? How I can achieve this?
If browser not support JavaScript then you can not display that message using JavaScript you need to use
<noscript> Message that has to display </noscript>
and you can apply css to it
if support and you want to check version using ng-device-detector is not possible because it only detect device types, OS types and browser name not version. I found this article which may help. If you still wanna use ng-device-detector here is GitHub source and this is plunker.

Force Employee To Use Firefox + Specified Version For Company Intranet

Please not not turn this into a discussion about which browser is better and the ethics of forcing a browser. It's an intranet, and it's what I am required to do so everyone calm down =o)
I need to prevent employees from trying to bypass the check to not use their preferred browser instead of the company mandated one + version. The decision was made based on security, compatibility, costs, and the use of company made Firefox extensions.
I came across this Force users to use Chrome/FireFox instead of IE which I can do easily in PHP to force use of Firefox, however it relies on the useragent which can easily be changed in numerous browsers and with the use of plugins.
Is there a JavaScript solution that I can use that DOES NOT check the useragent or any value that can be 'easily' modified by a user/plugin? It would need to detect if the browser is Firefox and what version it is. Site uses jQuery so if it can be done using that, however not required then by all means yes. I just am not aware of what ways to detect a browser and it's version that there are without checking useragent.
I remember way back in the day for detecting Netscape or some browser checking for document.all was used instead of useragent, so I'm guessing something similar, which only Firefox will have.
Thank you very much in advance!
Try this: http://jsfiddle.net/DerekL/62exH/
Because Firefox handles onpopstate differently than other browsers, you can then use this to detect if it is Firefox or not. This can not be changed by user or script. But the disadvantage is you can only get the version number by doing navigator.appVersion.
You can only try but cannot succeed in forcing a browser. That being said you can strip down the CSS in other browsers which may completely make your site close to unusable in other browsers.
To make your CSS only work with Firefox you can try approaches given # Targeting only Firefox with CSS

this.dataset works under Chrome now, is it going to be supported by FF too?

We are using data- prefix in our html tags to attach some data to our elements. We can get that data by this.dataset property in Chrome and as we are too lazy to check if our functions work under different browsers/engines(by the way i have to support FF and Chrome only, no safari, no IE), now our app is failing under FF because FF does not know what is "this.dataset". Is it going to be supported by FF too(our app is not going to be ready for a month or more), or should we re-write our code?
The patch for dataset support is not going to ship in a Firefox release until at least August. So if you need something in a month, you shouldn't rely on it.
See https://bugzilla.mozilla.org/show_bug.cgi?id=560112 for details.
In the meantime you can use polyfills for dataset so you can use that API:
http://eligrey.com/blog/post/html-5-dataset-support
https://github.com/remy/polyfills/blob/master/dataset.js
I'd rewrite it, as I haven't seen anything in gecko to suggest this is coming soon, and it's not particularly hard to write.
You may be interested to know that jQuery has it's $.data() method that does what you want – you may want to look at the source to see how they tackle this, or just to use it as is.

How to package JavaScript as a .NET Internet Explorer 9 Plugin?

How to .NET package JavaScript as an Interner Explorer 8/9 Plugin, with the JS to be included in all IE browser pages?
I have recently finished writing JavaScript code for a browser addon, which basically runs on page-load via a JS load event listener, and for given domains it then checks for certain elements in the DOM and adds new relevant elements(i.e. information) to the page.
Since the JavaScript only reads/affects the HTML DOM independently (and does not need any toolbar buttons or anything else) the JS purely needs adding to the browser's webpages.
I have packaged the code to work with Firefox and Chrome and those are both working well, and I can run the code for IE in 'bookmarklet' form without problems, but I would like to learn how to package JavaScript as an actual .NET .MSI addon/plugin that will install for the current Internet Explorer 8/9.
Does anyone know of a suitable guide or method I might refer to please? I have tried searching online for tutorials but most walkthroughs refer to writing the plugin body itself (usually in other languages) and are thus not regarding packing existing JS.
I hope someone might have the solution please?
Note: Someone packaged an old version for me as a MSI installer for Internet Explorer 7 a year ago, which installed into Program Files with a plugin.dll plugin.tlb and plugin.InstallState plus BandObjectLib.dll Interop.SHDocVw.dll and Microsoft.mshtml.dll if that is useful.
Edit: Does anyone else know of any other options please?
IE doesn't have a mechanism for this, there simply is no JavaScript based extension ecosystem (though there are other methods to create extensions) for those browsers, yet. IE8 won't be getting one, you can pretty much guarantee that, IE9...we'll see what happens.
The closest JavaScript option available to you would be bookmarklets, which have much more limited functionality...but it's what's available.
Check out http://www.add-in-express.com/programming-internet-explorer/ and http://www.add-in-express.com/programming-internet-explorer/deployment.php they sell a package for this. It will cost you 200 dollar, but will save you allot of time (atleast, It saved me allot of time :) ).
I found a tutorial to create a plugin that loads JS-Code
http://shout.setfive.com/2012/05/01/internet-explorer-extension-quick-start-and-skeleton/

Categories