以下整理在不同瀏覽器中偵測縮放比例的各種方式與實測結果。
window.devicePixelRatio : 2 (準確) screen.deviceXDPI / screen.logicalXDPI : NaN window.outerWidth / window.innerWidth : 2 document.documentElement.offsetHeight / window.innerHeight : 0.0206... (有相關性) window.top.outerWidth / window.top.innerWidth : 2
window.devicePixelRatio : 1.5 (準確) screen.deviceXDPI / screen.logicalXDPI : NaN window.outerWidth / window.innerWidth : 1.0114... document.documentElement.offsetHeight / window.innerHeight : 0.0233... (有相關性) window.top.outerWidth / window.top.innerWidth : 1.0114...
window.devicePixelRatio : undefined screen.deviceXDPI / screen.logicalXDPI : 1.5416... (大致準確) window.outerWidth / window.innerWidth : NaN document.documentElement.offsetHeight / window.innerHeight : NaN
window.devicePixelRatio : 1.5 (準確) screen.deviceXDPI / screen.logicalXDPI : 1.5 window.outerWidth / window.innerWidth : 1.0084... document.documentElement.offsetHeight / window.innerHeight : 0.0220... (有相關性)
window.devicePixelRatio : undefined screen.deviceXDPI / screen.logicalXDPI : 1.5 (準確) window.outerWidth / window.innerWidth : 1.0084... document.documentElement.offsetHeight / window.innerHeight : 1
window.devicePixelRatio : undefined screen.deviceXDPI / screen.logicalXDPI : 1 window.outerWidth / window.innerWidth : NaN
window.devicePixelRatio : 1 screen.deviceXDPI / screen.logicalXDPI : NaN window.outerWidth / window.innerWidth : 1.5 window.top.outerWidth / window.top.innerWidth : 1.5 (準確)
window.devicePixelRatio : undefined screen.deviceXDPI / screen.logicalXDPI : 1 window.outerWidth / window.innerWidth : NaN
window.devicePixelRatio : 1 screen.deviceXDPI / screen.logicalXDPI : NaN window.outerWidth / window.innerWidth : 2.0710... (大致準確)
綜合來看,window.devicePixelRatio 在支援它的瀏覽器(如 Chrome、Firefox、IE11)中最準確;舊版 IE 則可用 screen.deviceXDPI / screen.logicalXDPI 來近似推算縮放比例。