


//取得用户代理字符串 并全部小写。 var ua = navigator.userAgent.toLowerCase(); document.write(ua);
在上篇文章给大家介绍了基于javascript代码检测访问网页的浏览器呈现引擎、平台、Windows操作系统、移动设备和游戏系统
,感兴趣的朋友可以点击全文了解详情。
1、识别呈现引擎
引擎主要包含四种:IE、Gecko、WebKit、Opera
2、识别浏览器
主流浏览器包含四种:IE、Chrome、Firefox、Opera
3、识别平台
主流平台包含三类:Windows、Mac、Unix
4、识别Windows操作系统
Windows操作系统包含:Windows 98、Window NT、Window XP、Window Vista、Windows 7…
5、识别移动设备
主流的移动设备包含三类:iPhone、iPod、Anroid、Nokia
6、识别游戏系统。
主流的游戏系统包含两类:Wii、PS3。
网上发现的比较简单的区分代码:
JavaScript
var ua = navigator.userAgent.toLowerCase(); var isStrict = document.compatMode == "CSS1Compat" isOpera = ua.indexOf("opera") > -1 isChrome = ua.indexOf("chrome") > -1 isSafari = !isChrome && (/webkit|khtml/).test(ua) isSafari3 = isSafari && ua.indexOf('webkit/5') != -1 isIE = !isOpera && ua.indexOf("msie") > -1 isIE7 = !isOpera && ua.indexOf("msie 7") > -1 isIE8 = !isOpera && ua.indexOf("msie 8") > -1 isGecko = !isSafari && !isChrome && ua.indexOf("gecko") > -1 isGecko3 = isGecko && ua.indexOf("rv:1.9") > -1 isBorderBox = isIE && !isStrict isWin7 = ua.indexOf("nt 6.1") > -1 isVista = ua.indexOf("nt 6.0") > -1 isWin2003 = ua.indexOf("nt 5.2") > -1 isWinXp = ua.indexOf("nt 5.1") > -1 isWin2000 = ua.indexOf("nt 5.0") > -1 isWindows = (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) isMac = (ua.indexOf("macintosh") != -1 || ua.indexOf("mac os x") != -1) isAir = (ua.indexOf("adobeair") != -1) isLinux = (ua.indexOf("linux") != -1) var sys = ""; var broser = ""; if(isIE){ broser = "IE 6"; }else if(isIE7){ broser = "IE 7"; }else if(isIE8){ broser = "IE 8"; }else if(isOpera){ broser = "Opera"; }else if(isChrome){ broser = "Chrome"; }else if(isSafari){ broser = "Safari"; }else if(isSafari3){ broser = "Safari3"; }else{ broser = "Unknow"; } if(isWin7){ sys = "Windows 7"; }else if(isVista){ sys = "Vista"; }else if(isWinXp){ sys = "Windows xp"; }else if(isWin2003){ sys = "Windows 2003"; }else if(isWin2000){ sys = "Windows 2000"; }else if(isWindows){ sys = "Windows"; }else if(isMac){ sys = "Macintosh"; }else if(isAir){ sys = "Adobeair"; }else if(isLinux){ sys = "Linux"; }else{ sys = "Unknow"; } document.write(ua); alert(sys + ":" + broser);
比较全面的区分代码:
JavaScript
var client = function(){ //呈现引擎 var engine = { ie : 0, gecko : 0, webkit : 0, khtml : 0, opera : 0, //完整的版本号 ver : null }; //浏览器 var browser = { //主要浏览器 ie : 0, firefox : 0, konq : 0, opera : 0, chrome : 0, safari : 0, //具体的版本号 ver : null }; //平台、设备和操作系统 var system ={ win : false, mac : false, xll : false, //移动设备 iphone : false, ipod : false, nokiaN : false, winMobile : false, macMobile : false, //游戏设备 wii : false, ps : false }; //检测呈现引擎和浏览器 var ua = navigator.userAgent; if (window.opera){ engine.ver = browser.ver = window.opera.version(); engine.opera = browser.opera = parseFloat(engine.ver); } else if (/AppleWebKit\/(\S+)/.test(ua)){ engine.ver = RegExp["$1"]; engine.webkit = parseFloat(engine.ver); //确定是Chrome还是Safari if (/Chrome\/(\S+)/.test(ua)){ browser.ver = RegExp["$1"]; browser.chrome = parseFloat(browser.ver); } else if (/Version\/(\S+)/.test(ua)){ browser.ver = RegExp["$1"]; browser.safari = parseFloat(browser.ver); } else { //近似地确定版本号 var safariVersion = 1; if(engine.webkit < 100){ safariVersion = 1; } else if (engine.webkit < 312){ safariVersion = 1.2; } else if (engine.webkit < 412){ safariVersion = 1.3; } else { safariVersion = 2; } browser.safari = browser.ver = safariVersion; } } else if (/KHTML\/(\S+)/.test(ua) || /Konquersor\/([^;]+)/.test(ua)){ engine.ver = browser.ver = RegExp["$1"]; engine.khtml = browser.kong = paresFloat(engine.ver); } else if (/rv:([^\)]+)\) Gecko\/\d{8}/.test(ua)){ engine.ver = RegExp["$1"] engine.gecko = parseFloat(engine.ver); //确定是不是Firefox if (/Firefox\/(\S+)/.test(ua)){ browser.ver = RegExp["$1"]; browser.firefox = pareseFloat(browser.ver); } } else if(/MSIE([^;]+)/.test(ua)){ browser.ver = RegExp["$1"]; browser.firefox = parseFloat(browser.ver); } //检测浏览器 browser.ie = engine.ie; browser.opera = engine.opera; //检测平台 var p = navigator.platform; system.win = p.indexOf("Win") == 0; system.mac = p.indexOf("Mac") == 0; system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); //检测Windows操作系统 if (system.win){ if (/Win(?:doms)?([^do]{2})\s?(\d+\.\d+)?/.test(ua)){ if (RegExp["$1"] == "NT"){ switch(RegExp["$2"]){ case "5.0": system.win = "2000"; break; case "5.1": system.win = "XP"; break; case "6.0": system.win = "Vista"; break; default : system.win = "NT"; break; } } else if (RegExp["$1"]){ system.win = "ME"; } else { system.win = RegExp["$1"]; } } } //移动设备 system.iphone = ua.indexOf("iPhone") > -1; system.ipod = ua.indexOf("iPod") > -1; system.nokiaN = ua.indexOf("NokiaN") > -1; system.winMobile = (system.win == "CE"); system.macMobile = (system.iphone || system.ipod); //游戏系统 system.wii = ua.indexOf("Wii") > -1; system.ps = /playstation/i.test(ua); //返回这些对象 return { engine: engine, browser: browser, system: system }; }()
以上所述是小编给大家介绍的JavaScript学习笔记之检测客户端类型是(引擎、浏览器、平台、操作系统、移动设备)的全部叙述,希望大家喜欢。

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.

The power of the JavaScript framework lies in simplifying development, improving user experience and application performance. When choosing a framework, consider: 1. Project size and complexity, 2. Team experience, 3. Ecosystem and community support.

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
