I'm trying to detect the "Do not track" setting on browsers... the origionla working code is:
if(navigator.doNotTrack == "yes" || navigator.doNotTrack == "1" || navigator.msDoNotTrack == "1"){
alert("true");
}else{
alert("false");
}
I'm trying to re-write it slightly and I'm wondering how to use a conditional within a variable declaration? I've come up with a not-working snippet that I was wondering if someone could help me with?
var DNT = navigator.doNotTrack,
msDNT = navigator.msDoNotTrack,
DNTtrue = "yes" || "1";
if(DNT === DNTtrue || msDNT === DNTtrue){
alert("true");
}else{
alert("false");
}
DNTtrue = "yes" || "1";results totruedue to javascript lose typing. which means thisDNT === DNTtrueis equivalent toDNT === true"yes" || "1"results to"yes"