diff options
Diffstat (limited to 'files/zh-tw/web/http/headers/user-agent/index.html')
| -rw-r--r-- | files/zh-tw/web/http/headers/user-agent/index.html | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/files/zh-tw/web/http/headers/user-agent/index.html b/files/zh-tw/web/http/headers/user-agent/index.html new file mode 100644 index 0000000000..38bfe13cbf --- /dev/null +++ b/files/zh-tw/web/http/headers/user-agent/index.html @@ -0,0 +1,146 @@ +--- +title: User-Agent +slug: Web/HTTP/Headers/User-Agent +translation_of: Web/HTTP/Headers/User-Agent +--- +<div>{{HTTPSidebar}}</div> + +<p><span class="seoSummary">User-Agent 請求標頭(request header)含有能令網路協議同級層(peer)識別發出該<a href="/zh-TW/docs/Glossary/User_agent">用戶代理</a>請求的軟體類型或版本號、該軟體使用的作業系統、還有軟體開發者的字詞串。</span></p> + +<div class="note"> +<p>請讀讀<a href="/zh-TW/docs/Web/HTTP/Browser_detection_using_the_user_agent">透過用戶代理偵測瀏覽器</a>以理解為什麼給不同的瀏覽器不同的頁面或服務是餿主意。</p> +</div> + +<table class="properties"> + <tbody> + <tr> + <th scope="row">標頭類型</th> + <td>{{Glossary("Request header")}}</td> + </tr> + <tr> + <th scope="row">{{Glossary("Forbidden header name")}}</th> + <td>否</td> + </tr> + </tbody> +</table> + +<h2 id="語法">語法</h2> + +<pre class="syntaxbox">User-Agent: <product> / <product-version> <comment> +</pre> + +<p>瀏覽器常見格式:</p> + +<pre class="syntaxbox">User-Agent: Mozilla/5.0 (<system-information>) <platform> (<platform-details>) <extensions></pre> + +<p>網路瀏覽器常用的格式:</p> + +<pre class="syntaxbox">User-Agent: Mozilla/<version> (<system-information>) <platform> (<platform-details>) <extensions> +</pre> + +<h2 id="指令">指令</h2> + +<dl> + <dt><product></dt> + <dd>產品識別符:通常是名字或開發代號。</dd> + <dt><product-version></dt> + <dd>產品版本號。</dd> + <dt><comment></dt> + <dd>關於產品資訊的註解(如副產品訊息)。可能有、或沒有。</dd> +</dl> + +<h2 id="Firefox_UA_字串">Firefox UA 字串</h2> + +<p>關於 Firefox 和基於 Gecko 的用戶代理字串,請參閱 <a href="/zh-TW/docs/Web/HTTP/Headers/User-Agent/Firefox">Firefox 用戶代理字串參考</a>。Firefox 用戶代理字串大略上分成以下四個部份:</p> + +<p><strong>Mozilla/5.0 (<em>platform</em>; rv:<em>geckoversion</em>) Gecko/<em>geckotrail</em> Firefox/<em>firefoxversion</em></strong></p> + +<ol> + <li><code>Mozilla/5.0</code> is the general token that says the browser is Mozilla-compatible. For historical reasons, almost every browser today sends it.</li> + <li><strong><em>platform</em></strong> describes the native platform the browser is running on (Windows, Mac, Linux, Android, etc.), and if it's a mobile phone. <a href="/en-US/docs/Glossary/Firefox_OS">Firefox OS</a> phones simply say <code>Mobile</code> — the web is the platform. Note that <strong><em>platform</em></strong> can consist of multiple <code>"; "</code>-separated tokens. See below for further details and examples.</li> + <li><strong>rv:<em>geckoversion</em></strong> indicates the release version of Gecko (such as <em>"17.0"</em>). In recent browsers, <strong><em>geckoversion</em></strong> is the same as <strong><em>firefoxversion</em></strong>.</li> + <li><strong><em>Gecko/geckotrail</em></strong> indicates that the browser is based on <a href="/en-US/docs/Mozilla/Gecko">Gecko</a>. (On Desktop, <em><strong>geckotrail</strong></em> is always the fixed string <code>20100101</code>.)</li> + <li><em><strong>Firefox/firefoxversion</strong></em> indicates the browser is Firefox, and provides the version (such as "<em>17.0"</em>).</li> +</ol> + +<h3 id="示例">示例</h3> + +<pre>Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0 +Mozilla/5.0 (Macintosh; Intel Mac OS X <em>x.y</em>; rv:42.0) Gecko/20100101 Firefox/42.0 +</pre> + +<h2 id="Chrome_用戶代理字串">Chrome 用戶代理字串</h2> + +<p>Chrome(或基於 Chromium/blink 引擎的瀏覽器)的用戶代理字串看起來像 Firefox。出於相容性的理由,它還會加上「KHTML, like Gecko」與「Safari」的字串。</p> + +<h3 id="字串">字串</h3> + +<pre>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36</pre> + +<h2 id="Opera_用戶代理字串">Opera 用戶代理字串</h2> + +<p>因為 Opera 瀏覽器的引擎也是基於 blink 的,所以語法也看起來也會很像。不過,還會加上「 OPR/<version>」一詞。</p> + +<h3 id="示例_2">示例</h3> + +<pre>Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36 OPR/38.0.2220.41</pre> + +<p>Opera 在使用 Presto 排版時的用戶代理字串</p> + +<pre class="no-line-numbers">Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00 +Opera/9.60 (Windows NT 6.0; U; en) Presto/2.1.1</pre> + +<h2 id="Safari_用戶代理字串">Safari 用戶代理字串</h2> + +<p>此例的 safari 用戶代理字串是攜帶版,所以會出現「Mobile」一詞。</p> + +<h3 id="示例_3">示例</h3> + +<pre>Mozilla/5.0 (Linux; U; Android 4.0.3; de-ch; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30</pre> + +<h2 id="Internet_Explorer_用戶代理字串">Internet Explorer 用戶代理字串</h2> + +<h3 id="示例_4">示例</h3> + +<pre>Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)</pre> + +<h2 id="網路爬蟲與機器人的用戶代理字串">網路爬蟲與機器人的用戶代理字串</h2> + +<h3 id="示例_5">示例</h3> + +<pre>Googlebot/2.1 (+http://www.google.com/bot.html)</pre> + +<h2 id="規範">規範</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">規範</th> + <th scope="col">標題</th> + </tr> + <tr> + <td>{{RFC(7231, "User-Agent", "5.5.3")}}</td> + <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</td> + </tr> + <tr> + <td>{{RFC(2616, "User-Agent", "14.43")}}</td> + <td>Hypertext Transfer Protocol -- HTTP/1.1</td> + </tr> + </tbody> +</table> + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("http.headers.User-Agent")}}</p> + +<h2 id="參閱">參閱</h2> + +<ul> + <li><a href="https://hacks.mozilla.org/2013/09/user-agent-detection-history-and-checklist/">User-Agent detection, history and checklist</a></li> + <li><a href="/zh-TW/docs/Web/HTTP/Headers/User-Agent/Firefox">Firefox 用戶代理字串參考</a></li> + <li> + <p><a href="/zh-TW/docs/Web/HTTP/Browser_detection_using_the_user_agent">透過用戶代理偵測瀏覽器</a></p> + </li> +</ul> |
