JS access to the client operating system function code (1:VISTA,2:WINDOWS7,3:2000,4:XP,5:2003,6:2008) _javascript tips

Source: Internet
Author: User

Copy Code code as follows:

Obtain client operating system (1:VISTA,2:WINDOWS7,3:2000,4:XP,5:2003,6:2008)
function Getosinfo () {
var _pf = Navigator.platform;
var appver = navigator.useragent;
if (_PF = = "Win32" | | _pf = = "Windows")
{
if (appVer.indexOf ("WOW64") >-1) {
_bit = "64 bits";
}else{
_bit = "32 bits";
}
if (appVer.indexOf ("Windows NT 6.0") >-1 | | | appver.indexof ("Windows Vista") >-1)
{
if (_bit== ' 64-bit ' | | | appver.indexof ("Windows Vista") >-1) {
Return ' Windows_vista ' +_bit;
}else{
return "Unknow1";
}
}else if (appVer.indexOf ("Windows NT 6.1") >-1 | | appver.indexof ("Windows 7") >-1) {
if (_bit== ' 32-bit ' | | | appver.indexof ("Windows 7") >-1) {
Return ' windows_7 ' +_bit;
}else{
return "Unknow";
}
}else {
try{
var _winname = Array (' Watts ', ' XP ', ' 2003 ');
var _ntnum = Appver.match (/windows NT 5.\d/i). toString ();
Return ' Windows_ ' + _winname[_ntnum.replace (/windows NT 5. ( \d)/I, "$"]+ "" +_bit;
}catch (e) {return ' Windows ';}
}
}else if (_PF = "mac68k" | | _pf = = "MACPPC" | | _pf = "Macintosh")
{
return "Mac";
}else if (_PF = = "X11")
{
return "Unix";
}else if (String (_PF). IndexOf ("Linux") >-1)
{
return "Linux";
}else
{
return "Unknow";
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.