BlackBerry Web Design: window size (window height) returning the wrong value in the Blackberry simulator

{ var winH = $(window).height(); var winW = $(window).width(); } 

I print winH and winW, giving incorrect values โ€‹โ€‹in the Blackberry simulator and on the real device (BB 9800)

Decision:

In blackberry widgets, window width and window height using jquery give wrong values. Solution { var winH = screen.height; var winW = screen.width; var winH = screen.height; var winW = screen.width; }

+4
source share
2 answers

I found the same problem and here is my solution. This is due to the pixel ratio of the device. That is, in pc, the ratio between pixels in css and pixels on the screen is 1: 1

However, in some devices this ratio changes to 1: 2.24 or to different values

My solution was:

 var winW = screen.width*window.devicePixelRatio; var winH = screen.height*window.devicePixelRatio; 
0
source

I also had the same problem and I used the return correct values

 var widthh = window.innerWidth; var heightt = window.innerHeight 
0
source

All Articles