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. error: Failed dependencies: rpm安装包失败报错依赖包

    error: Failed dependencies: mysql-community-release conflicts with (installed) mysql57-community-rel ...

  2. linux--关于JVM CPU资源占用过高的问题排查

    一.背景: 先执行一个java程序里面开了两个线程分别都在while循环做打印操作. # java -cp ./test-threads.jar com.spiro.Main 二.现象: 通过top命 ...

  3. Centos 7 Rabbitmq 安装并开机启动

    准备工作 安装wget yum install -y wget rabbitmq安装需要依赖erlang,erlang安装参考:https://www.cnblogs.com/swyy/p/11582 ...

  4. 多线程c++11编程题目

    /*题目:子线程循环 10 次,接着主线程循环 100 次,接着又回到子线程循环 10 次,接着再回到主线程又循环 100 次. 如此循环50次,试写出代码.子线程与主线程必有一个满足条件(flag ...

  5. 一个cgi的例子

    cgi的详细资料可以参考 http://httpd.apache.org/docs/2.4/howto/cgi.html 下面是一个python实现的cgi脚本,里面体现了一些cgi的用法,使用其他脚 ...

  6. python模块----configpaser (key:value型 配置文件解析器)

    configparser是用来读取配置文件的包,配置文件的格式类似:[section]+内容(键=值) 标准库网址:https://docs.python.org/3/library/configpa ...

  7. pugixml应用随笔

    1.   修改元素值 second_node.set_value("miller");不对 必须second_node.first_child().set_value(" ...

  8. Mac通过docker一键部署airflow

    目录 Airflow部署及使用 1.Dockerhub查看镜像地址 2.拉取docker镜像 3.在宿主机创建外挂文件夹 4.创建docker容器 5.重新创建docker容器 5.1.查看airfl ...

  9. ST在keil下开发时候文件options配置的一些小技巧

    作者:良知犹存 转载授权以及围观:欢迎添加微信公众号:Conscience_Remains 总述     这是之前ST芯片载keil下开发时候总结的一些代码文件options配置小笔记,虽然不是很复杂 ...

  10. Codeforces Round #666 (Div. 2)

    比赛链接:https://codeforces.com/contest/1397 A. Juggling Letters 题意 给出 $n$ 个字符串,可在字符串间任意移动字母,问最终能否使这 $n$ ...