瀏覽器縮放檢測(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(完全沒(méi)反應(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)確)
搜狗高速瀏覽器 (完全沒(méi)反應(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ù)庫(kù)所有表DatabaseMetaData的用法(詳解)
- JavaScript實(shí)現(xiàn)移動(dòng)端頁(yè)面按手機(jī)屏幕分辨率自動(dòng)縮放的最強(qiáng)代碼
- jQuery實(shí)現(xiàn)響應(yīng)瀏覽器縮放大小并改變背景顏色
- Iphone手機(jī)、安卓手機(jī)瀏覽器控制默認(rèn)縮放大小的方法總結(jié)(附代碼)
相關(guān)文章
網(wǎng)頁(yè)前端登錄js按Enter回車(chē)鍵實(shí)現(xiàn)登陸的兩種方法
下面小編就為大家?guī)?lái)一篇網(wǎng)頁(yè)前端登錄js按Enter回車(chē)鍵實(shí)現(xiàn)登陸的兩種方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考2016-05-05
基于JS實(shí)現(xiàn)html中placeholder屬性提示文字效果示例
這篇文章主要介紹了基于JS實(shí)現(xiàn)html中placeholder屬性提示文字效果,涉及javascript事件響應(yīng)及頁(yè)面元素屬性動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2018-04-04
JavaScript實(shí)現(xiàn)網(wǎng)頁(yè)端播放攝像頭實(shí)時(shí)畫(huà)面
這篇文章主要介紹了如何利用JavaScript實(shí)現(xiàn)在網(wǎng)頁(yè)端播放局域網(wǎng)(不能上云)或是廣域網(wǎng)的攝像頭的實(shí)時(shí)畫(huà)面,文中的示例代碼講解詳細(xì),需要的可以參考一下2022-02-02
使用JavaScript獲取URL參數(shù)的方法總結(jié)
在?JavaScript?中,獲取?URL?參數(shù)是非常常見(jiàn)的操作,這篇文章為大家整理了四個(gè)JavaScript常見(jiàn)的獲取URL參數(shù)方法,希望對(duì)大家有所幫助2024-12-12
利用js實(shí)現(xiàn)可進(jìn)行時(shí)間和工作調(diào)度的任務(wù)管理器
這篇文章主要為大家詳細(xì)介紹了如何利用js實(shí)現(xiàn)一個(gè)可進(jìn)行時(shí)間和工作調(diào)度的任務(wù)管理器,文中的示例代碼簡(jiǎn)潔易懂,有需要的小伙伴可以參考一下2023-10-10
JS基于Ajax實(shí)現(xiàn)的網(wǎng)頁(yè)Loading效果代碼
這篇文章主要介紹了JS基于Ajax實(shí)現(xiàn)的網(wǎng)頁(yè)Loading效果代碼,通過(guò)時(shí)間函數(shù)結(jié)合數(shù)學(xué)運(yùn)算實(shí)現(xiàn)頁(yè)面樣式的動(dòng)態(tài)變換技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-10-10

