<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>@GBreagan</title>
<script type='text/javascript'>
/**
* Browser properties:
* -fullName (Opera, Google Chrome, Mozilla Firefox...)
* -name (opera, chrome, firefox...)
* -code (op, ch, ff...)
* -fullVersion (5.0.3.12...)
* -version (5)
* -mobile (true, false)
* -platform (windows 7, Linux, Machintosh...)
* @author Rbrt
* @version 2.1.5
* @returns Browser object
*/
function Browser() {
// ---- public properties -----
this.fullName = 'unknown'; // getName(false);
this.name = 'unknown'; // getName(true);
this.code = 'unknown'; // getCodeName(this.name);
this.fullVersion = 'unknown'; // getVersion(this.name);
this.version = 'unknown'; // getBasicVersion(this.fullVersion);
this.mobile = false; // isMobile(navigator.userAgent);
this.width = screen.width;
this.height = screen.height;
this.platform = 'unknown'; //getPlatform(navigator.userAgent);
// ------- init -------
this.init = function() { //operative system, is an auxiliary var, for special-cases
//the first var is the string that will be found in userAgent. the Second var is the common name
// IMPORTANT NOTE: define new navigators BEFORE firefox, chrome and safari
var navs = [
{ name:'Opera Mobi', fullName:'Opera Mobile', pre:'Version/' },
{ name:'Opera Mini', fullName:'Opera Mini', pre:'Version/' },
{ name:'Opera', fullName:'Opera', pre:'Version/' },
{ name:'MSIE', fullName:'Microsoft Internet Explorer', pre:'MSIE ' },
{ name:'BlackBerry', fullName:'BlackBerry Navigator', pre:'/' },
{ name:'BrowserNG', fullName:'Nokia Navigator', pre:'BrowserNG/' },
{ name:'Midori', fullName:'Midori', pre:'Midori/' },
{ name:'Kazehakase', fullName:'Kazehakase', pre:'Kazehakase/' },
{ name:'Chromium', fullName:'Chromium', pre:'Chromium/' },
{ name:'Flock', fullName:'Flock', pre:'Flock/' },
{ name:'Galeon', fullName:'Galeon', pre:'Galeon/' },
{ name:'RockMelt', fullName:'RockMelt', pre:'RockMelt/' },
{ name:'Fennec', fullName:'Fennec', pre:'Fennec/' },
{ name:'Konqueror', fullName:'Konqueror', pre:'Konqueror/' },
{ name:'Arora', fullName:'Arora', pre:'Arora/' },
{ name:'Swiftfox', fullName:'Swiftfox', pre:'Firefox/' },
{ name:'Maxthon', fullName:'Maxthon', pre:'Maxthon/' },
// { name:'', fullName:'', pre:'' } //add new broswers
// { name:'', fullName:'', pre:'' }
{ name:'Firefox',fullName:'Mozilla Firefox', pre:'Firefox/' },
{ name:'Chrome', fullName:'Google Chrome', pre:'Chrome/' },
{ name:'Safari', fullName:'Apple Safari', pre:'Version/' }
];
var agent = navigator.userAgent, pre;
//set names
for (i in navs) {
if (agent.indexOf(navs[i].name)>-1) {
pre = navs[i].pre;
this.name = navs[i].name.toLowerCase(); //the code name is always lowercase
this.fullName = navs[i].fullName;
if (this.name=='msie') this.name = 'iexplorer';
if (this.name=='opera mobi') this.name = 'opera';
if (this.name=='opera mini') this.name = 'opera';
break; //when found it, stops reading
}
}//for
//set version
if ((idx=agent.indexOf(pre))>-1) {
this.fullVersion = '';
this.version = '';
var nDots = 0;
var len = agent.length;
var indexVersion = idx + pre.length;
for (j=indexVersion; j<len; j++) {
var n = agent.charCodeAt(j);
if ((n>=48 && n<=57) || n==46) { //looking for numbers and dots
if (n==46) nDots++;
if (nDots<2) this.version += agent.charAt(j);
this.fullVersion += agent.charAt(j);
}else j=len; //finish sub-cycle
}//for
this.version = parseInt(this.version);
}
// set Mobile
var mobiles = ['mobi', 'mobile', 'mini', 'iphone', 'ipod', 'ipad', 'android', 'blackberry'];
for (var i in mobiles) {
if (agent.toLowerCase().indexOf(mobiles[i])>-1) this.mobile = true;
}
if (this.width<700 || this.height<600) this.mobile = true;
// set Platform
var plat = navigator.platform;
if (plat=='Win32' || plat=='Win64') this.platform = 'Windows';
if (agent.indexOf('NT 5.1') !=-1) this.platform = 'Windows XP';
if (agent.indexOf('NT 6') !=-1) this.platform = 'Windows Vista';
if (agent.indexOf('NT 6.1') !=-1) this.platform = 'Windows 7';
if (agent.indexOf('Mac') !=-1) this.platform = 'Macintosh';
if (agent.indexOf('Linux') !=-1) this.platform = 'Linux';
if (agent.indexOf('iPhone') !=-1) this.platform = 'iOS iPhone';
if (agent.indexOf('iPod') !=-1) this.platform = 'iOS iPod';
if (agent.indexOf('iPad') !=-1) this.platform = 'iOS iPad';
if (agent.indexOf('Android') !=-1) this.platform = 'Android';
if (this.name!='unknown') {
this.code = this.name+'';
if (this.name=='opera') this.code = 'op';
if (this.name=='firefox') this.code = 'ff';
if (this.name=='chrome') this.code = 'ch';
if (this.name=='safari') this.code = 'sf';
if (this.name=='iexplorer') this.code = 'ie';
if (this.name=='maxthon') this.code = 'mx';
}
//manual filter, when is so hard to define the navigator type
if (this.name=='safari' && (this.platform=='Linux' || this.platform=='Android')) {
this.name = 'unknown';
this.fullName = 'unknown';
this.code = 'unknown';
}
if (this.name=='unknown') {
if (agent.toLowerCase().indexOf('webkit')) this.fullName = 'unknown webkit navigator';
}
};//function
this.init();
}//Browser class
var brw = new Browser();
alert('fullName: ' + brw.fullName + '\n' + 'name: ' + brw.name + '\n' + 'fullVersion: ' + brw.fullVersion + '\n' + 'version: ' + brw.version + '\n' + 'platform: ' + brw.platform+ '\n' + 'mobile: ' + brw.mobile+ '\n' + 'resolution: ' + brw.width + 'x' + brw.height);
</script>
</head>
</html>