1
votes

Using a Iphone 4s with retina display - the phone dimensions are 640 x 960.

why is it that when I get the screen.width and screen.height in javascript in any browser then the dimensions returned are 320 x 480.

The samsung s4 also return inaccurate values to.

  1. what is the browser/javascript doing to calculate this.

  2. how does this whole process work technically?

1

1 Answers

1
votes

The size of the screen in pixels is 320x480 no matter the model. From: http://www.idev101.com/code/User_Interface/sizes.html The 4s displays twice as many pixels into the space which is where the difference comes in.

Points vs. Pixels

Apple introduced retina displays starting with the iPhone 4. These have twice as many screen pixels as previous iPhones. You don't have to modify your code to support high-res displays; the iOS coordinate system uses points rather than pixels, so the dimensions and position in points of all UI elements remains the same across all devices.