Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xgqfrms opened this issue Mar 24, 2021 · 3 comments
Open

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

xgqfrms opened this issue Mar 24, 2021 · 3 comments
Labels
js & screen resolution & 5K & 4K js & screen resolution & 5K & 4K

Comments

@xgqfrms
Copy link
Owner

xgqfrms commented Mar 24, 2021

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

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

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}`);
}

// test
getResolution();
// Your screen resolution is: 3840 x 2160

盗版

https://www.debugcn.com/en/article/44749128.html

@xgqfrms
Copy link
Owner Author

xgqfrms commented Mar 24, 2021

iMac 5K

image

image

@xgqfrms
Copy link
Owner Author

xgqfrms commented Mar 24, 2021

dell 4K

image

image

@xgqfrms xgqfrms added the js & screen resolution & 5K & 4K js & screen resolution & 5K & 4K label Mar 24, 2021
@xgqfrms
Copy link
Owner Author

xgqfrms commented Mar 24, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js & screen resolution & 5K & 4K js & screen resolution & 5K & 4K
Projects
None yet
Development

No branches or pull requests

1 participant