Detect Gecko Version (not build) working JS provided! :-)
Posted: Wed Jan 25, 2006 1:12 pm
What the provided JavaScript does is exactly what I want to do only I want to do it in PHP! Only one extra step, I want to assign $gecko to whatever version the Gecko engine is (to deal with Gecko bugs that have lingered longer then insert something wity here).
For example, Firefox 1.5's UA is...
Anyway here is the working JavaScript.
For example, Firefox 1.5's UA is...
So if we printed out the variable we'd get...Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
But I simply have no clue how to do this in PHP!1.8
Anyway here is the working JavaScript.
John<script type="text/javascript">
<!--
var str = navigator.userAgent;
/***
/^rv\:|\).*$/g
***/
var gecko = str.replace(/^Mozilla.*rv:|\).*$/g, '' ) || ( /^rv\:|\).*$/g, '' );
document.writeln(gecko);
var version = gecko.substring(0,3);
if (version == 1.6) {document.writeln('<br />1.6')}
else if (version == 1.7) {document.writeln('<br />1.7')}
else if (version == 1.8) {document.writeln('<br />1.8')}
else if (version == 1.9) {document.writeln('<br />1.9')}
else {document.writeln('<br />Unknown Gecko code')};
//-->
</script>