diad
diad

Reputation: 41

Get device height in cordova

I am trying to find device's height in Cordova?

pChart.chartHeight = 100;

What can I write instead of 100? 100 should be the device's height.

Upvotes: 3

Views: 1825

Answers (3)

d_z90
d_z90

Reputation: 1263

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. Try this:

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

productionChart.chartHeight = physicalScreenHeight;

And have a look here in case you have more doubts.

Upvotes: 2

tmv2613
tmv2613

Reputation: 11

use .resize()

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

Upvotes: 1

Navneeth
Navneeth

Reputation: 988

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

Upvotes: 0

Related Questions