Dieser Artikel beschreibt die Methode, um Client -Betriebssystemtypen nach JS zu erhalten. Teilen Sie es für Ihre Referenz wie folgt weiter:
<! DocType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>jsJudge client operating system type</title></head><body><script language="javascript">function detectOS() { var suseragent = navigator.useragent; var iswin = (navigator.platform == "Win32") || (Navigator.Platform == "Windows"); var ismac = (navigator.Platform == "mac68k") || (Navigator.Platform == "macppc") || (Navigator.Platform == "Macintosh") || (Navigator.Platform == "MacinTel"); Wenn (ismac) "macOS" zurückgibt; var isunix = (navigator.platform == "x11") &&! iswin &&! ismac; wenn (isunix) zurück "unix"; var isLinux = (String (navigator.Platform) .Indexof ("Linux")> -1); Wenn (isLinux) "Linux" zurückgibt; if (iswin) {var iswin2k = suseragent.indexof ("Windows NT 5.0")> -1 || suseragent.indexof ("Windows 2000")> -1; if (iswin2k) zurück "Windows2000"; var iswinxp = suseragent.indexof ("Windows NT 5.1")> -1 || suseragent.indexof ("Windows XP")> -1; if (iswinxp) zurück "Windows XP" zurückgeben; var iswin2003 = suseragent.indexof ("Windows NT 5.2")> -1 || suseragent.indexof ("Windows NT 5.2")> -1; if (iswin2003) zurück "Windows NT 6.0")> -1 || Suseragent.Indexof ("Windows Vista")> -1; Wenn (iswinvista) "Windows Vista" zurückgeben; var iswin7 = suseragent.indexof ("Windows NT 6.1")> -1 || Suseragent.Indexof ("Windows 7")> -1; Wenn (iswin7) "Windows7" zurückgeben; } return "other";} document.writeln ("Ihr Betriebssystem ist:" + detektos ()); </script> </body> </html>PS: Übrigens verwendet das IP Home Query Tool des Online -Tools dieser Website auch die oben genannte Methode, um den Betriebssystemtyp des Benutzers zu beurteilen. wie folgt:
Online -Query -Tool für IP -Adresse Home Standort:
http://tools.vevb.com/aideddesign/ipcha
Übrigens möchte ich Ihnen einige weitere praktische JS -Online -Format -Tools für Sie empfehlen. Ich glaube, dass sie in zukünftigen Entwicklung häufig verwendet werden:
C Sprachstil/HTML/CSS/JSON -Code -Formatierung und Verschönerungswerkzeuge:
http://tools.vevb.com/code/ccode_html_css_json
Online -Tools für JavaScript -Code Verschönerung und Formatierung:
http://tools.vevb.com/code/js
JavaScript Code Verschönerung/Komprimierung/Formatierung/Verschlüsselungstools:
http://tools.vevb.com/code/jscompress
Online -JSON -Code -Überprüfung, Inspektion, Verschönerung und Formatierungswerkzeuge:
http://tools.vevb.com/code/json
JSON -Code Online -Formatierung/Verschönerung/Komprimierung/Bearbeitung/Konvertieren von Tools:
http://tools.vevb.com/code/jsoncodeFormat
For more information about JavaScript, please check this site's special topics: "Summary of Ajax Operation Skills in JavaScript", "Summary of JSON Operation Skills in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging Techniken "," Zusammenfassung von JavaScript -Datenstrukturen und Algorithmus -Techniken ", Zusammenfassung von JavaScript -Traversal -Algorithmen und -Techniken" und "Zusammenfassung der Verwendung von JavaScript -Mathematikoperationen"
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.