简体   繁体   English

如何在WinRT JavaScript应用程序中获得屏幕分辨率?

[英]How to get the screen resolution in WinRT JavaScript app?

No duplicate of get screen resolution winrt 获取屏幕分辨率winrt没有重复

Above is possible in C# etc. but not in JavaScript. 以上是可能的C#等,但不是在JavaScript中。

SO how can I get screen resolution in a JavaScript WinRT app? 那我如何在JavaScript WinRT应用程序中获得屏幕分辨率?

One way is to use the window object and get the width and height: 一种方法是使用window对象并获得宽度和高度:

var width = window.outerWidth;
var height = window.outerHeight;

Keep in mind that, while the WinJS stuff in WinRT apps doesn't translate back to the web browser platform, anything on the web browser platform should translate directly into WinRT apps. 请记住,虽然WinRT应用程序中的WinJS内容不会转换回Web浏览器平台,但Web浏览器平台上的任何内容都应直接转换为WinRT应用程序。 So any approach for getting the window's dimensions in a browser should work in the WinRT app as well. 因此,任何在浏览器中获取窗口尺寸的方法也应该适用于WinRT应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM