瀏覽器縮放檢測(cè)的js代碼
測(cè)試代碼
效果:
chrome
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
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
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
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
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
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))
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(準(zhǔn)確)
搜狗高速瀏覽器 (完全沒反應(yīng))
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 (大致準(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實(shí)現(xiàn)移動(dòng)端頁面按手機(jī)屏幕分辨率自動(dòng)縮放的最強(qiáng)代碼
- jQuery實(shí)現(xiàn)響應(yīng)瀏覽器縮放大小并改變背景顏色
- Iphone手機(jī)、安卓手機(jī)瀏覽器控制默認(rèn)縮放大小的方法總結(jié)(附代碼)
相關(guān)文章
uniapp介紹與使用以及小程序?qū)崟r(shí)獲取視頻播放時(shí)間
這篇文章主要給大家介紹了關(guān)于uniapp介紹與使用以及小程序?qū)崟r(shí)獲取視頻播放時(shí)間的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用uniapp具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-02-02bootstrap使用validate實(shí)現(xiàn)簡(jiǎn)單校驗(yàn)功能
這篇文章主要為大家詳細(xì)介紹了bootstrap使用validate實(shí)現(xiàn)簡(jiǎn)單校驗(yàn)功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12JavaScript實(shí)現(xiàn)table切換的插件封裝
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)table切換的插件封裝,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-10-10Add Formatted Text to a Word Document
Add Formatted Text to a Word Document...2007-06-06原生JS實(shí)現(xiàn)幾個(gè)常用DOM操作API實(shí)例
下面小編就為大家?guī)硪黄鶭S實(shí)現(xiàn)幾個(gè)常用DOM操作API實(shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-01-01js實(shí)現(xiàn)輪播圖效果 純js實(shí)現(xiàn)圖片自動(dòng)切換
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)輪播圖效果,圖片自動(dòng)切換,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-08-08Bootstrap每天必學(xué)之模態(tài)框(Modal)插件
Bootstrap每天必學(xué)之模態(tài)框(Modal)插件,模態(tài)框(Modal)是覆蓋在父窗體上的子窗體。通常,目的是顯示來自一個(gè)單獨(dú)的源的內(nèi)容,可以在不離開父窗體的情況下有一些互動(dòng)。子窗體可提供信息、交互等,感興趣的小伙伴們可以參考一下2016-04-04