简体   繁体   English

在cordova中获取设备高度

[英]Get device height in cordova

I am trying to find device's height in Cordova? 我想在Cordova找到设备的高度?

pChart.chartHeight = 100;

What can I write instead of 100 ? 我能写什么而不是100 100 should be the device's height. 100应该是设备的高度。

use .resize() 使用.resize()

$( window ).resize(function() {
  alert($(window).height() + $(window).width);
});

From window.screen you can obtain its width and height properties, but you should also add the pixel densities since it may change on orientation or among different devices. window.screen您可以获得其宽度和高度属性,但您还应该添加像素密度,因为它可能会在方向上或在不同设备之间发生变化。 Try this: 尝试这个:

var physicalScreenHeight = window.screen.height * window.devicePixelRatio;

productionChart.chartHeight = physicalScreenHeight;

And have a look here in case you have more doubts. 如果您有更多疑问,请查看此处

Try this. 试试这个。

var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

alert(w +" - "+h);

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

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