Archive for August, 2011

Detect operating system user side in javascript


// This script sets OSName variable as follows:
// “Windows” for all versions of Windows
// “MacOS” for all versions of Macintosh OS
// “Linux” for all versions of Linux
// “UNIX” for all other UNIX flavors
// “Unknown OS” indicates failure to detect the OS

var OSName=”Unknown OS”;
if (navigator.appVersion.indexOf(“Win”)!=-1){
OSName=”win_styles”;
document.write(”);
}
if (navigator.appVersion.indexOf(“Mac”)!=-1){
OSName=”mac_styles”;
document.write(”);
}
/*if (navigator.appVersion.indexOf(“X11″)!=-1){
OSName=”UNIX”;
}
if (navigator.appVersion.indexOf(“Linux”)!=-1){
OSName=”Linux”;
}*/

Screen width & Detect Safari browser in Javascript


////// get screen width ////////
var scr = screen.width;
if(scr>1024){
//test
}

////// detect user safari browser ////////
var browser = navigator.userAgent;
if (browser.toLowerCase().indexOf(‘safari’) > 0){
//detect browser
}