javascript - Get screen resolution independent of zoom in Firefox -
the existing answer incorrect: detect real screen resolution (ignoring browser zoom etc.)
it not show screen resolution, rather document size.
is there way screen resolution in firefox, when zoom applied?
ok, https://github.com/mp31415 have 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 retina displays otherwise works fine.
Comments
Post a Comment