Home > Article > Web Front-end > Example of JS getting browser version and operating system version_javascript skills
So, we can write the following code:
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: