I’m currently working on a site that detects the browser version by checking for various JS objects:
var is = {
ff: window.globalStorage,
ie: document.all && !window.opera,
ie6: !window.XMLHttpRequest,
ie7: document.all && window.XMLHttpRequest && !XDomainRequest && !window.opera,
ie8: document.documentMode==8,
opera: Boolean(window.opera),
chrome: Boolean(window.chrome),
safari: window.getComputedStyle && !window.globalStorage && !window.opera
}
However this doesn’t work in FireFox 4. Does anyone know what objects to check for, when you want to detect FF4?
Just check for something that was introduced with Gecko 2.0, such as selection.modify:
and window.globalStorage won’t return all versions of FF, as it requires Gecko 1.8.1 / FF2