Is Firefox a browser is almost always the wrong question. Of course, you can start to crawl through the User-Agent , but it is so often misleading that it should not be touched, except as a last resort.
This is also a wavy question, since there are many browsers that are not Firefox, but are based on the same code, so they are almost the same. Is it SeaMonkey Firefox? Is it Flock Firefox? Is Fennec Firefox? Is it Iceweasel Firefox? Is Firebird (or Phoenix!) Firefox? Is Minefield Firefox?
The best route is to pinpoint why you want to relate to Firefox differently and to think about this thing. For example, if you want to get around the error in Gecko, you can try to cause this error and find the wrong answer from the script.
If this is not possible for any reason, a common way to sniff out the Gecko renderer is to check for the Mozilla property. For example:
if ('MozBinding' in document.body.style) { document.getElementById('hellononfirefoxers').style.display= 'none'; }
edit: if you need to run the test in <head> , before the body or target div is in the document, you can do something like:
<style type="text/css"> html.firefox #somediv { display: none } </style> <script type="text/javascript"> if ('MozBinding' in document.documentElement.style) { document.documentElement.className= 'firefox'; } </script>
bobince
source share