瀏覽器縮放檢測的js代碼
更新時間:2014年09月28日 23:19:13 作者:99js
這篇文章主要介紹了瀏覽器縮放檢測的js代碼,需要的朋友可以參考下
測試代碼
效果:
chrome
復(fù)制代碼 代碼如下:
window.devicePixelRatio : 2 (準(zhǔn)確)
screen.deviceXDPI / screen.logicalXDPI : NaN
window.outerWidth / window.innerWidth : 2
document.documentElement.offsetHeight / window.innerHeight : 0.020618556701030927 (有相關(guān)性)
window.top.outerWidth / window.top.innerWidth : 2
ff
復(fù)制代碼 代碼如下:
window.devicePixelRatio : 1.5 (準(zhǔn)確)
screen.deviceXDPI / screen.logicalXDPI : NaN
window.outerWidth / window.innerWidth : 1.0114583333333333
document.documentElement.offsetHeight / window.innerHeight : 0.023391812865497075 (有相關(guān)性)
window.top.outerWidth / window.top.innerWidth : 1.0114583333333333
ie 8
復(fù)制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1.5416666666666667 (大致準(zhǔn)確)
window.outerWidth / window.innerWidth : NaN
document.documentElement.offsetHeight / window.innerHeight : NaN
window.top.outerWidth / window.top.innerWidth : NaN
ie11
復(fù)制代碼 代碼如下:
window.devicePixelRatio : 1.5 (準(zhǔn)確)
screen.deviceXDPI / screen.logicalXDPI : 1.5
window.outerWidth / window.innerWidth : 1.0084033613445377
document.documentElement.offsetHeight / window.innerHeight : 0.02203856749311295 (有相關(guān)性)
window.top.outerWidth / window.top.innerWidth : 1.0084033613445377
ie10
復(fù)制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1.5 (準(zhǔn)確)
window.outerWidth / window.innerWidth : 1.0084033613445377
document.documentElement.offsetHeight / window.innerHeight : 1
window.top.outerWidth / window.top.innerWidth : 1.0084033613445377
ie9
復(fù)制代碼 代碼如下:
window.devicePixelRatio : undefined
screen.deviceXDPI / screen.logicalXDPI : 1.5 (準(zhǔn)確)
window.outerWidth / window.innerWidth : 1.0084033613445377
document.documentElement.offsetHeight / window.innerHeight : 1
window.top.outerWidth / window.top.innerWidth : 1.0084033613445377
360 6.3(完全沒反應(yīng))
復(fù)制代碼 代碼如下:
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極速瀏覽器
復(fù)制代碼 代碼如下:
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(準(zhǔn)確)
搜狗高速瀏覽器 (完全沒反應(yīng))
復(fù)制代碼 代碼如下:
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
淘寶瀏覽器
復(fù)制代碼 代碼如下:
window.devicePixelRatio : 1
screen.deviceXDPI / screen.logicalXDPI : NaN
window.outerWidth / window.innerWidth : 2.0710059171597632 (大致準(zhǔn)確)
document.documentElement.offsetHeight / window.innerHeight : 0.022988505747126436
window.top.outerWidth / window.top.innerWidth : 2.0710059171597632
您可能感興趣的文章:
- 關(guān)于meta viewport中target-densitydpi屬性詳解(推薦)
- 自適應(yīng)布局meta標(biāo)簽中viewport、content、width、initial-scale、minimum-scale、maximum-scale總結(jié)
- java 查詢oracle數(shù)據(jù)庫所有表DatabaseMetaData的用法(詳解)
- JavaScript實現(xiàn)移動端頁面按手機(jī)屏幕分辨率自動縮放的最強(qiáng)代碼
- jQuery實現(xiàn)響應(yīng)瀏覽器縮放大小并改變背景顏色
- Iphone手機(jī)、安卓手機(jī)瀏覽器控制默認(rèn)縮放大小的方法總結(jié)(附代碼)
相關(guān)文章
uniapp介紹與使用以及小程序?qū)崟r獲取視頻播放時間
這篇文章主要給大家介紹了關(guān)于uniapp介紹與使用以及小程序?qū)崟r獲取視頻播放時間的相關(guān)資料,文中通過實例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用uniapp具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2023-02-02bootstrap使用validate實現(xiàn)簡單校驗功能
這篇文章主要為大家詳細(xì)介紹了bootstrap使用validate實現(xiàn)簡單校驗功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12JavaScript實現(xiàn)table切換的插件封裝
這篇文章主要為大家詳細(xì)介紹了JavaScript實現(xiàn)table切換的插件封裝,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-10-10Add Formatted Text to a Word Document
Add Formatted Text to a Word Document...2007-06-06js實現(xiàn)輪播圖效果 純js實現(xiàn)圖片自動切換
這篇文章主要為大家詳細(xì)介紹了js實現(xiàn)輪播圖效果,圖片自動切換,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-08-08Bootstrap每天必學(xué)之模態(tài)框(Modal)插件
Bootstrap每天必學(xué)之模態(tài)框(Modal)插件,模態(tài)框(Modal)是覆蓋在父窗體上的子窗體。通常,目的是顯示來自一個單獨的源的內(nèi)容,可以在不離開父窗體的情況下有一些互動。子窗體可提供信息、交互等,感興趣的小伙伴們可以參考一下2016-04-04