Home >Web Front-end >JS Tutorial >Use Javascript to determine the type of operating system to achieve compatibility under different operating systems_javascript skills

Use Javascript to determine the type of operating system to achieve compatibility under different operating systems_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:42:41999browse

When realizing the interaction between the client and the server through Javascript, sometimes it is necessary to judge the operating system in order to achieve compatibility under different operating systems. For example: we have a website that works well under Windows XP, but when it comes to Ubuntu , due to many different features, will cause subtle differences in browsing, and even affect a good user experience. At this time, we need to use Javascript to judge the type of operating system and certain features, divide and conquer, so as to maintain a good user experience when the website is browsed across platforms.
The code below implements the judgment of Windows, Mac, Linux, and Unix operating systems:

Copy the code The code is as follows:



if we need For more accurate identification of the Windows operating system, you can continue to use the following code operation:
Copy the code The code is as follows:



The following code is to detect whether the browser supports XML features:
Copy code The code is as follows:



PS: In order to better avoid different browsers and different operations The system affects the page layout due to different default text. You should try to avoid using fixed line height (height:12px;) in CSS to limit the text height. You should try to use height:auto. If you have to limit the text height (for example, only display (one line), em should be used instead of px (for example, height: 1.1em;), 1em=1 text height, so that the text height changes dynamically with the text size without causing text truncation.
Statement:
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