Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Created November 14, 2012 18:12
Show Gist options
  • Save steveosoule/4073759 to your computer and use it in GitHub Desktop.
Save steveosoule/4073759 to your computer and use it in GitHub Desktop.
JavaScript Browser Info
// JavaScript Document// Example:
// var b = new BrowserInfo();
// alert(b.version);
function BrowserInfo(){
this.name = navigator.appName;
this.codename = navigator.appCodeName;
this.version = navigator.appVersion.substring(0, 4);
this.platform = navigator.platform;
this.javaEnabled = navigator.javaEnabled();
this.screenWidth = screen.width;
this.screenHeight = screen.height;
alert(this.name);
}
function platformDetect(){
if(navigator.appVersion.indexOf("Win") != -1){
alert("Windows");
}
else if(navigator.appVersion.indexOf("Mac") != -1){
alert("Macintosh");
}
else alert("Other");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment