aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/navigator/donottrack/index.html
blob: 5b6535ae975f5540dbc97893bb3d4e8bbb67804b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
title: Navigator.doNotTrack
slug: Web/API/Navigator/doNotTrack
translation_of: Web/API/Navigator/doNotTrack
---
<p>{{ ApiRef("HTML DOM") }}{{SeeCompatTable}}</p>

<h3 id="Summary" name="Summary">概述</h3>

<p>返回用户的do-not-track设置,如果用户不允许网站,内容和广告等进行跟踪,则该值为yes.</p>

<h3 id="Syntax" name="Syntax">语法</h3>

<pre class="eval"><em>dnt</em> = <em>navigator</em>.doNotTrack;
</pre>

<p><strong><code>navigator.doNotTrack</code></strong>的值并不是 <strong>HTTP请求中do-not-track请求头的值</strong>. 当do-not-track请求头发送的值为"1", <code>navigator.doNotTrack</code> 的值为 "yes".  当do-not-track请求头发送的值为unset, <code>navigator.doNotTrack</code>的值为"unspecified". 当do-not-track请求头发送的值为 "0" (Firefox目前不支持), <code>navigator.doNotTrack</code>的值为"no".</p>

<h3 id="Example" name="Example">例子</h3>

<pre class="eval">dump(window.navigator.doNotTrack);
//Firefox中:如果开启了DNT,输出"yes";否则输出"unspecified".
</pre>

<h3 id="Specification" name="Specification">规范</h3>

<p><a class="external" href="http://www.w3.org/TR/tracking-dnt/" title="http://www.w3.org/TR/tracking-dnt/">Tracking Preference Expression</a> (工作草案)</p>

<h3 id="相关链接">相关链接</h3>

<ul>
 <li><a href="/zh-cn/The_Do_Not_Track_Field_Guide" title="https://developer.mozilla.org/zh-cn/The_Do_Not_Track_Field_Guide">The Do Not Track field guide</a></li>
</ul>

<h3 id="浏览器兼容性">浏览器兼容性</h3>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatGeckoDesktop("9.0") }}</td>
   <td>9</td>
   <td>12</td>
   <td>5.1 on OS X 10.7</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatGeckoMobile("9.0") }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<ul>
 <li>IE9 中该属性带有ms前缀:navigator.msDoNotTrack</li>
 <li>IE9, Opera 12和Safari 5.1 实现了早起的旧版本规范:<code>navigator.doNotTrack</code> 的值就是 do-not-track 请求头中的值.</li>
</ul>

<p>{{ languages( { "en": "en/DOM/navigator.doNotTrack" } ) }}</p>