Navigator:doNotTrack 属性

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

非标准: 该特性是非标准的,请尽量不要在生产环境中使用它!

Navigator.doNotTrack 属性返回用户的请勿追踪设置,该设置指示用户是否请求网站和广告商不要追踪他们。

该属性的值反映了 DNT HTTP 标头的值,即 "1""0"null 值。

字符串或 null

示例

js
console.log(navigator.doNotTrack);
// 如果启用了 DNT,则返回 "1";如果用户选择加入跟踪,则返回 "0";否则返回 null。

规范

No specification found

No specification data found for api.Navigator.doNotTrack.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
doNotTrack
DeprecatedNon-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.

参见

  • DNT HTTP 标头