如何判断浏览你的网页的用户用的操作系统,这一点javascript可以办到,下面是代码:
function
detectOS()
... {
var sUserAgent = navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh");
if(isMac) return "Mac";
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if(isUnix) return "Unix";
if(isWin)
...{
var isWin95 = sUserAgent.indexOf("Win95") > -1 || sUserAgent.indexOf("Windows 95") > -1;
if(isWin95) return "Win95";
var isWin98 = sUserAgent.indexOf("Win98") > -1 || sUserAgent.indexOf("Windows 98") > -1;
if(isWin98) return "Win98";
var isWinME = sUserAgent.indexOf("Windows 9x 4.90") > -1 || sUserAgent.indexOf("Windows ME") > -1;
if(isWinME) return "WinME";
var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
if(isWin2K) return "Win2000";
var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
if(isWinXP) return "WinXP";
}
return "None";
}
... {
var sUserAgent = navigator.userAgent;
var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh");
if(isMac) return "Mac";
var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
if(isUnix) return "Unix";
if(isWin)
...{
var isWin95 = sUserAgent.indexOf("Win95") > -1 || sUserAgent.indexOf("Windows 95") > -1;
if(isWin95) return "Win95";
var isWin98 = sUserAgent.indexOf("Win98") > -1 || sUserAgent.indexOf("Windows 98") > -1;
if(isWin98) return "Win98";
var isWinME = sUserAgent.indexOf("Windows 9x 4.90") > -1 || sUserAgent.indexOf("Windows ME") > -1;
if(isWinME) return "WinME";
var isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
if(isWin2K) return "Win2000";
var isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
if(isWinXP) return "WinXP";
}
return "None";
}