Javascript 以cordova为单位获取设备高度
我想在科尔多瓦找到设备的高度Javascript 以cordova为单位获取设备高度,javascript,jquery,cordova,Javascript,Jquery,Cordova,我想在科尔多瓦找到设备的高度 pChart.chartHeight = 100; 我可以写什么来代替100100应该是设备的高度。试试这个 var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; var h = window.innerHeight || document.documentElement.clientHeight || document.bo
pChart.chartHeight = 100;
我可以写什么来代替100
100应该是设备的高度。试试这个
var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;
var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
alert(w +" - "+h);
使用
从window.screen
可以获得其宽度和高度属性,但也应该添加像素密度,因为它可能会在方向上或不同设备之间发生变化。试试这个:
var physicalScreenHeight = window.screen.height * window.devicePixelRatio;
productionChart.chartHeight = physicalScreenHeight;
如果您有更多疑问,请查看。可能重复:@Rory McCrossan window.innerWidth不起作用您正在阅读问题,请检查答案:不起作用window.innerWidth当旋转屏幕时其他条件应起作用。请尝试document.documentElement.clientHeightI我需要定向lanscape
var physicalScreenHeight = window.screen.height * window.devicePixelRatio;
productionChart.chartHeight = physicalScreenHeight;