Home > Web Front-end > JS Tutorial > Example of JS getting browser version and operating system version_javascript skills

Example of JS getting browser version and operating system version_javascript skills

WBOY
Release: 2016-05-16 16:48:40
Original
1411 people have browsed it

So, we can write the following code:

Copy the code The code is as follows:

Among them, judgment expressions such as the ternary operator are used to simplify the code. The judgment condition is an assignment statement, which not only completes the matching of regular expressions and copy the results, but also directly serves as a conditional judgment. The subsequent version information only needs to be extracted from the previous matching results. This is a very efficient code.

In the future, you only need to use if(Sys.ie) or if(Sys.firefox) to judge a certain browser, and you only need to use if(Sys.ie == '8.0') or if to judge the browser version. (Sys.firefox == '3.0') and other forms are still very elegant to express.

Get the operating system version:

Copy the code The code is as follows:

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template