blob: 1c1eabd8bb2e9fa37da85637a1000c19e1e99e38 (
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
|
---
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>
{{Compat("api.Navigator.doNotTrack")}}
|