此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Navigator:doNotTrack 属性

Deprecated

Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.

非标准: 该特性尚未标准化。我们不建议在生产环境中使用非标准特性,因为它们在浏览器中的支持有限,且可能发生变化或被移除。不过,在没有标准选项的特定情况下,它们可以作为合适的替代方案。

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

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

字符串或 null

示例

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

规范

此特性似乎未在任何规范中定义。

浏览器兼容性

参见

  • DNT HTTP 标头