One of the top keyword searches on this blog is ‘detect ie6 mootools‘; As popular as this search term is, it’s not actually covered, so this post should fill that gap!
The Mootools developers are code purists; Extending their browser class would be easy but they do not want to do it. They do provide a method to get the browser build and this could be used along with the remaining browser string to work out the version. Essentially, they like to keep their code relevant and streamlined.
This can be combined with the Mootools browser class to produce browser variables.
//declare global variables var WEBKIT = Browser.Engine.webkit; var GECKO = Browser.Engine.gecko; var OPERA = Browser.Engine.presto; var IE = Browser.Engine.trident; var IE6 = (navigator.userAgent.toLowerCase().indexOf('msie 6') != -1) && (navigator.userAgent.toLowerCase().indexOf('msie 7') == -1); //test variables (delete) if(WEBKIT) alert("WEBKIT"); if(GECKO) alert("GECKO"); if(OPERA) alert("OPERA"); if(IE) alert("IE"); if(IE6) alert("IE6");