瀏覽器縮放檢測的js代碼
更新時間:2014年09月28日 23:19:13 作者:99js
這篇文章主要介紹了瀏覽器縮放檢測的js代碼,需要的朋友可以參考下
測試代碼
效果:
chrome
復制代碼 代碼如下:
window.devicePixelRatio : 2 (準確)
screen.deviceXDPI / screen.logicalXDPI : NaN
window.outerWidth / window.innerWidth : 2
document.documentElement.offsetHeight / window.innerHeight : 0.020618556701030927 (有相關性)
window.top.outerWidth / window.top.innerWidth : 2
ff
復制代碼 代碼如下:
window.devicePixelRatio : 1.5 (準確)
screen.deviceXDPI / screen.logicalXDPI : NaN
window.outerWidth / window.innerWidth : 1.0114583333333333
document.documentElement.offsetHeight / window.innerHeight : 0.023391812865497075 (有相關性)
window.top.outerWidth / window.top.innerWidth : 1.0114583333333333
ie 8
復制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1.5416666666666667 (大致準確)
window.outerWidth / window.innerWidth : NaN
document.documentElement.offsetHeight / window.innerHeight : NaN
window.top.outerWidth / window.top.innerWidth : NaN
ie11
復制代碼 代碼如下:
window.devicePixelRatio : 1.5 (準確)
screen.deviceXDPI / screen.logicalXDPI : 1.5
window.outerWidth / window.innerWidth : 1.0084033613445377
document.documentElement.offsetHeight / window.innerHeight : 0.02203856749311295 (有相關性)
window.top.outerWidth / window.top.innerWidth : 1.0084033613445377
ie10
復制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1.5 (準確)
window.outerWidth / window.innerWidth : 1.0084033613445377
document.documentElement.offsetHeight / window.innerHeight : 1
window.top.outerWidth / window.top.innerWidth : 1.0084033613445377
ie9
復制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1.5 (準確)
window.outerWidth / window.innerWidth : 1.0084033613445377
document.documentElement.offsetHeight / window.innerHeight : 1
window.top.outerWidth / window.top.innerWidth : 1.0084033613445377
360 6.3(完全沒反應)
復制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1
window.outerWidth / window.innerWidth : NaN
document.documentElement.offsetHeight / window.innerHeight : NaN
window.top.outerWidth / window.top.innerWidth : NaN
360極速瀏覽器
復制代碼 代碼如下:
window.devicePixelRatio : 1
screen.deviceXDPI / screen.logicalXDPI : NaN
window.outerWidth / window.innerWidth : 1.5
document.documentElement.offsetHeight / window.innerHeight : 0.015267175572519083
window.top.outerWidth / window.top.innerWidth : 1.5(準確)
搜狗高速瀏覽器 (完全沒反應)
復制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1
window.outerWidth / window.innerWidth : NaN
document.documentElement.offsetHeight / window.innerHeight : NaN
window.top.outerWidth / window.top.innerWidth : NaN
淘寶瀏覽器
復制代碼 代碼如下:
window.devicePixelRatio : 1
screen.deviceXDPI / screen.logicalXDPI : NaN
window.outerWidth / window.innerWidth : 2.0710059171597632 (大致準確)
document.documentElement.offsetHeight / window.innerHeight : 0.022988505747126436
window.top.outerWidth / window.top.innerWidth : 2.0710059171597632
相關文章
網頁前端登錄js按Enter回車鍵實現(xiàn)登陸的兩種方法
下面小編就為大家?guī)硪黄W頁前端登錄js按Enter回車鍵實現(xiàn)登陸的兩種方法。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考2016-05-05
基于JS實現(xiàn)html中placeholder屬性提示文字效果示例
這篇文章主要介紹了基于JS實現(xiàn)html中placeholder屬性提示文字效果,涉及javascript事件響應及頁面元素屬性動態(tài)操作相關實現(xiàn)技巧,需要的朋友可以參考下2018-04-04
JavaScript實現(xiàn)網頁端播放攝像頭實時畫面
這篇文章主要介紹了如何利用JavaScript實現(xiàn)在網頁端播放局域網(不能上云)或是廣域網的攝像頭的實時畫面,文中的示例代碼講解詳細,需要的可以參考一下2022-02-02
JS基于Ajax實現(xiàn)的網頁Loading效果代碼
這篇文章主要介紹了JS基于Ajax實現(xiàn)的網頁Loading效果代碼,通過時間函數(shù)結合數(shù)學運算實現(xiàn)頁面樣式的動態(tài)變換技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-10-10

