簡體   English   中英

在cordova中獲取設備高度

[英]Get device height in cordova

我想在Cordova找到設備的高度?

pChart.chartHeight = 100;

我能寫什么而不是100 100應該是設備的高度。

使用.resize()

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

window.screen您可以獲得其寬度和高度屬性,但您還應該添加像素密度,因為它可能會在方向上或在不同設備之間發生變化。 嘗試這個:

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

productionChart.chartHeight = physicalScreenHeight;

如果您有更多疑問,請查看此處

試試這個。

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