The existing answer is incorrect: Detect real screen resolution (ignoring browser zoom etc.)
It will not show the screen resolution, but rather the document size.
Is there a way to get screen resolution in Firefox, even when zoom is applied?
The existing answer is incorrect: Detect real screen resolution (ignoring browser zoom etc.)
It will not show the screen resolution, but rather the document size.
Is there a way to get screen resolution in Firefox, even when zoom is applied?
OK, thanks to https://github.com/mp31415 I have a working solution:
var isIE = function () {
if(navigator.appName === "Microsoft Internet Explorer") {
return true;
} else if(navigator.appName === "Netscape" && /Trident/.test(navigator.userAgent)) { // IE 11
return true;
}
return false;
};
var isFF = function () {
return !!navigator.userAgent.match(/firefox/i);
};
var sw = screen.width;
var sh = screen.height;
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) {
sh = this.round10(sh * zoom);
sw = this.round10(sw * zoom);
}
This code returns resolution scaled for Retina displays but otherwise works fine.