{"id":379,"date":"2025-12-02T14:58:12","date_gmt":"2025-12-02T06:58:12","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=379"},"modified":"2025-12-02T14:58:12","modified_gmt":"2025-12-02T06:58:12","slug":"navigator%ef%bc%9auseragent-%e5%b1%9e%e6%80%a7%e8%8e%b7%e5%8f%96%e8%ae%be%e5%a4%87%e6%b5%8f%e8%a7%88%e5%99%a8%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/12\/02\/navigator%ef%bc%9auseragent-%e5%b1%9e%e6%80%a7%e8%8e%b7%e5%8f%96%e8%ae%be%e5%a4%87%e6%b5%8f%e8%a7%88%e5%99%a8%e4%bf%a1%e6%81%af\/","title":{"rendered":"Navigator\uff1auserAgent \u5c5e\u6027\u83b7\u53d6\u8bbe\u5907\u6d4f\u89c8\u5668\u4fe1\u606f"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60 <strong>\u6700\u5168\u3001\u6700\u5b9e\u7528\u7684 Navigator.userAgent \u83b7\u53d6\u6d4f\u89c8\u5668\u4fe1\u606f\u6307\u5357<\/strong>\uff0c\u542b\u793a\u4f8b\u4e0e UA \u8bc6\u522b\u6280\u5de7\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83c\udf10 Navigator.userAgent\uff1a\u83b7\u53d6\u8bbe\u5907\u6d4f\u89c8\u5668\u4fe1\u606f<\/h1>\n\n\n\n<p>\u5728\u6d4f\u89c8\u5668\u4e2d\u53ef\u4ee5\u901a\u8fc7 <strong><code>navigator.userAgent<\/code><\/strong> \u8bfb\u53d6\u5f53\u524d\u8bbe\u5907\u7684\u6d4f\u89c8\u5668 UA\uff08User-Agent\uff09\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<p>\u8fd9\u662f\u524d\u7aef\u6700\u5e38\u7528\u7684\u73af\u5883\u8bc6\u522b\u65b9\u5f0f\u4e4b\u4e00\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2b50 \u4e00\u3001\u6700\u57fa\u672c\u7528\u6cd5<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconsole.log(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<p>\u8f93\u51fa\u4e00\u822c\u662f\u7c7b\u4f3c\u8fd9\u6837\u7684\u5b57\u7b26\u4e32\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMozilla\/5.0 (Windows NT 10.0; Win64; x64) \nAppleWebKit\/537.36 (KHTML, like Gecko) \nChrome\/120.0.0.0 Safari\/537.36\n\n<\/pre><\/div>\n\n\n<p>\u5b83\u5305\u542b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7cfb\u7edf\u7c7b\u578b\uff08Windows \/ Mac \/ Linux \/ Android \/ iOS\uff09<\/li>\n\n\n\n<li>\u6d4f\u89c8\u5668\u5f15\u64ce\uff08WebKit \/ Gecko\uff09<\/li>\n\n\n\n<li>\u6d4f\u89c8\u5668\u7c7b\u578b\uff08Chrome \/ Safari \/ Firefox \/ Edge\uff09<\/li>\n\n\n\n<li>CPU \u67b6\u6784\uff08x64 \/ ARM\uff09<\/li>\n\n\n\n<li>\u7248\u672c\u53f7<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2b50 \u4e8c\u3001\u4f7f\u7528 UA \u5224\u65ad\u7cfb\u7edf\u7c7b\u578b\u793a\u4f8b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 \u5224\u65ad\u662f\u5426\u662f\u79fb\u52a8\u7aef<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isMobile = \/Android|iPhone|iPad|iPod\/i.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u2714 \u5224\u65ad\u662f\u5426\u662f Android<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isAndroid = \/Android\/i.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u2714 \u5224\u65ad\u662f\u5426\u662f iOS<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isIOS = \/iPhone|iPad|iPod\/i.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u2714 \u5224\u65ad\u662f\u5426\u662f Windows<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isWindows = \/Windows NT\/i.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2b50 \u4e09\u3001\u5224\u65ad\u6d4f\u89c8\u5668\u7c7b\u578b<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u2714 Chrome<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isChrome = \/Chrome\\\/\\d+\/.test(navigator.userAgent) &amp;amp;&amp;amp; !\/Edg\/.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u2714 Edge\uff08\u65b0\u5185\u6838\uff09<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isEdge = \/Edg\\\/\\d+\/.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u2714 Firefox<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isFirefox = \/Firefox\\\/\\d+\/.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u2714 Safari\uff08iOS \u6216 macOS\uff09<\/h3>\n\n\n\n<p>Safari \u6ca1\u6709 \u201cChrome\u201d \u6216 \u201cEdge\u201d \u6807\u8bb0\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst isSafari = \/Safari\/.test(navigator.userAgent) &amp;amp;&amp;amp; !\/Chrome|Edg|OPR\/.test(navigator.userAgent);\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2b50 \u56db\u3001UA \u5b9e\u9645\u793a\u4f8b\uff08\u5e38\u7528\u8bbe\u5907\uff09<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcf1 iPhone 14 Safari<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMozilla\/5.0 (iPhone; CPU iPhone OS 17_2 like Mac OS X) \nAppleWebKit\/605.1.15 (KHTML, like Gecko) Version\/17.2 Mobile\/15E148 Safari\/604.1\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcf1 Android Chrome<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMozilla\/5.0 (Linux; Android 13; Pixel 6) \nAppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/120.0.0.0 Mobile Safari\/537.36\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcbb Windows 10 + Chrome<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMozilla\/5.0 (Windows NT 10.0; Win64; x64) \nAppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/120.0.0.0 Safari\/537.36\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcbb macOS Chrome<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMozilla\/5.0 (Macintosh; Intel Mac OS X 10_15_7) \nAppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/142.0.0.0 Safari\/537.36\n\n<\/pre><\/div>\n\n\n<p>\ud83d\udc49 <strong>\u4f60\u73b0\u5728\u7684 UA \u6b63\u662f\u8fd9\u4e00\u7c7b\uff1amacOS 10.15.7 + Chrome<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2b50 \u4e94\u3001\u6ce8\u610f\uff1auserAgent \u5df2\u9010\u6b65\u88ab\u5e9f\u5f03\uff08\u4f46\u4ecd\u53ef\u7528\uff09<\/h2>\n\n\n\n<p>Chrome \/ Safari \/ Firefox \u90fd\u5728\u9010\u6b65\u51cf\u5c11 UA \u7684\u8be6\u7ec6\u5ea6\uff0c\u4e3a\u4e86\u9690\u79c1\u5b89\u5168\u3002<br>\u66ff\u4ee3\u65b9\u6848\uff1a<strong>Navigator User-Agent Client Hints\uff08UA-CH\uff09<\/strong>\u3002<\/p>\n\n\n\n<p>\u83b7\u53d6\u65b9\u5f0f\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nnavigator.userAgentData.getHighEntropyValues(&#x5B;\n    &quot;platform&quot;, &quot;platformVersion&quot;, &quot;uaFullVersion&quot;, &quot;architecture&quot;, &quot;model&quot;\n]).then(console.log);\n\n<\/pre><\/div>\n\n\n<p>\u4f46 <strong>\u517c\u5bb9\u6027\u4e0d\u5982 userAgent<\/strong>\uff0c\u5f88\u591a\u65e7\u8bbe\u5907\u548c\u65e7\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60 \u6700\u5168\u3001\u6700\u5b9e\u7528\u7684 Navigator.userAgent \u83b7\u53d6\u6d4f\u89c8\u5668\u4fe1\u606f&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/12\/02\/navigator%ef%bc%9auseragent-%e5%b1%9e%e6%80%a7%e8%8e%b7%e5%8f%96%e8%ae%be%e5%a4%87%e6%b5%8f%e8%a7%88%e5%99%a8%e4%bf%a1%e6%81%af\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"class_list":["post-379","post","type-post","status-publish","format-standard","hentry","category-12"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=379"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/379\/revisions"}],"predecessor-version":[{"id":380,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/379\/revisions\/380"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}