getScreenResolution is zoom dependent for IE and FF
Author: mp31415Created Dec 10, 2015Updated Sep 13, 2026
Labelsbughelp wanted
In Chrome getScreenResolution (screen.height, screen.width, screen.availHeight, screen.availWidth) is zoom independent, however in IE and FF these values change upon zoom in/zoom out. (Not sure about Safari/Opera). It makes fingerprint less stable I think. The extra code I use to deal with the issue is the following:
getScreenResolution: function(keys) {
this.getScreenResolutionOrAvail(keys, screen.width, screen.height);
this.getScreenResolutionOrAvail(keys, screen.availWidth, screen.availHeight);
return keys;
},
getScreenResolutionOrAvail: function(keys, saw, sah) {
var res;
if(saw && sah) {
var zoom = 1;
if (this.isIE()) {
zoom = screen.deviceXDPI / screen.systemXDPI;
zoom = this.round5(zoom*100)/100;
}
else if (this.isFF()) {
zoom = window.devicePixelRatio;
}
if (zoom != 1) {
sah = this.round10(sah * zoom);
saw = this.round10(saw * zoom);
}
res = (sah > saw) ? [sah, saw] : [saw, sah];
}
if(typeof res !== "undefined") { // headless browsers
keys.push(res);
}
return keys;
},
round5: function (x)
{
return Math.round(x/5)*5;
},
round10: function (x)
{
return Math.round(x/10)*10;
},Source: fingerprintjs/fingerprintjs