How to get the real screen size(screen resolution) by using js

获取用户屏幕的真实像素分辨率, 屏幕实际尺寸

window.devicePixelRatio

设备像素比

screen resolution

屏幕分辨率

function getResolution() {
const realWidth = window.screen.width * window.devicePixelRatio;
const realHeight = window.screen.height * window.devicePixelRatio;
console.log(`
Your screen resolution is: ${realWidth} x ${realHeight}
Your screen devicePixelRatio is: ${window.devicePixelRatio}
`);
} // test
getResolution();
// Your screen resolution is: 3840 x 2160

retina screen bug

视网膜屏幕错误

refs

https://stackoverflow.com/questions/65462643/how-to-get-the-real-screen-sizescreen-resolution-by-using-js/65463713#65463713



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


How to get the real screen size(screen resolution) by using js的更多相关文章

  1. iPhone 6 Screen Size and Web Design Tips

    Apple updated its iPhone a bit ago making the form factor much bigger. The iPhone 6 screen size is b ...

  2. iPhone screen size

      iPhone 4 iPhone 5 iPhone 6 iPhone 6 Plus Display Size 3.5 in 4 in 4.7 in 5.5 in Screen Size 320 x ...

  3. js screen size check

    js screen size check js 屏幕尺寸检测 window.screen API screen; window.screen.width; window.screen.height; ...

  4. screen.height && screen.width

    screen.height && screen.width how to get window max width in js screen.height; screen.width; ...

  5. JS window对象 screen对象 screen对象用于获取用户的屏幕信息。 语法: window.screen.属性

    screen对象 screen对象用于获取用户的屏幕信息. 语法: window.screen.属性 对象属性:

  6. 1. Change the emulator screen size

    1. "Windows" ==> "Android Virtual Device Manager" ==> Select one emulator ...

  7. ABAP:区别CALL SCREEN/SET SCREEN/LEAVE TO SCREEN

    1,CALL SCREEN XXXX将在Screen调用栈(CALL STACK)上面添加一层调用(进栈),调用XXXX的PBO和PAI,如果XXXX的Next Screen不为0,那么将继续其Nex ...

  8. 区别CALL SCREEN/SET SCREEN/LEAVE TO SCREEN

    分类: 1,CALL SCREEN XXXX将在Screen调用栈(CALL STACK)上面添加一层调用(进栈),调用XXXX的PBO和PAI,如果XXXX的Next Screen不为0,那么将继续 ...

  9. javascript_获取浏览器属性

    navigator.appName:浏览器名称: navigator.appVersion:浏览器版本: navigator.language:浏览器设置的语言: navigator.platform ...

随机推荐

  1. Docker容器日志清理方案

    Docker容器在运行过程中会产生很多日志,久而久之,磁盘空间就被占满了,以下分享docker容器日志清理的几种方法 删除日志 在linux上,容器日志一般存放在 /var/lib/docker/co ...

  2. ovsdb-client命令

    ovsdb-server 的命令行接口. 查看有哪些数据库: ovsdb-client list-dbs [server] 查看数据库 schema: ovsdb-client get-schema ...

  3. SELECT ... FOR UPDATE or SELECT ... FOR SHARE Locking Reads session

    小结: 1.注意使用限制 Locking reads are only possible when autocommit is disabled (either by beginning transa ...

  4. Exception 异常处理

    https://github.com/jazzband/django-redis/blob/master/django_redis/exceptions.py django-redis/base.py ...

  5. 最小生成树-Prim&Kruskal

    Prim算法 算法步骤 S:当前已经在联通块中的所有点的集合 1. dist[i] = inf 2. for n 次 t<-S外离S最近的点 利用t更新S外点到S的距离 st[t] = true ...

  6. HDU - 6761 Minimum Index (字符串,Lyndon分解)

    Minimum Index 题意 求字符串所有前缀的所有后缀表示中字典序最小的位置集合,最终转换为1112进制表示.比如aab,有三个前缀分别为a,aa,aab.其中a的后缀只有一个a,位置下标1:a ...

  7. hdu3559 Frost Chain (概率dp+记忆化搜索)

    Problem Description In the unimaginable popular DotA game, the hero Lich has a wonderful skill: Fros ...

  8. 神奇C语言的字串处理库函数

    头文件:#incldue<string.h> 定义:strstr(str1,str2) 函数用于判断字符串str2是否是str1的子串.如果是,则该函数返回str2在str1中首次出现的地 ...

  9. S - Layout (最短路&&差分约束)

    Like everyone else, cows like to stand close to their friends when queuing for feed. FJ has N (2 < ...

  10. hdu 3549Flow Problem

    Problem Description Network flow is a well-known difficult problem for ACMers. Given a graph, your t ...