Javascript仅检测到“不跟踪” IE11中的设置 [英] Javascript only detection of "Do not track" settings in IE11
问题描述
我想在仅使用javascript的所有浏览器中尊重DNT设置(我没有服务器端访问主机服务器)。我从 https://stackoverflow.com/a/16947583/266960 获得以下内容
I would like to respect the DNT settings in all browsers using only javascript (I don't have server side access to the host server). I got the following from https://stackoverflow.com/a/16947583/266960
var isDNT = navigator.doNotTrack == "yes" || navigator.doNotTrack == "1" || navigator.msDoNotTrack == "1";
这适用于所有浏览器,但IE11(特别是11.0.9600.16428贯穿[ http://spoon.net/] ),它似乎不符合上述任何BOM属性(我尝试设置DNT首选项)通过互联网选项>高级>安全:始终发送不跟踪标题,并通过安全>打开跟踪保护)。
This works in all browsers but IE11 (specifically 11.0.9600.16428 run through [http://spoon.net/]), which does not seem to honour any of the above BOM properties (I tried setting the DNT preference via the Internet Options > Advanced > Security: "Always send a do not track header" and also via Safety > Turn on tracking protection).
任何人都可以确认这是正确(即IE11中的错误),或建议使用JS方法来检测这些设置?
Can anyone else confirm this is correct (i.e. a bug in IE11), or suggest a JS only method to detect those settings?
TIA
Ben
TIA Ben
推荐答案
根据来自Microsoft的回答:标准已更新从IE11开始,将 doNotTrack
属性放在窗口
对象上。
As per this answer from Microsoft: "The standard was updated" as of IE11, placing the doNotTrack
property on the window
object instead.
并非所有浏览器都是最新的,只有IE11和Safari 6.1.1+此时更新为p这个窗口属性表。
Not all browsers are up to date with this yet, only IE11 and Safari 6.1.1+ have updated at this time as per this window properties table.
撰写本文时,Mozilla目前正在分歧/讨论是否有doNotTrack应该是一个窗口或导航器属性。
As of this writing there is a current disagreement/discussion from Mozilla as to whether doNotTrack should be a window or navigator property.
这篇关于Javascript仅检测到“不跟踪” IE11中的设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!