Gideon Isaac
Gideon Isaac

Reputation: 405

How do I know how many physical inches a device screen has?

I have a website that needs to distinguish between mobile phones, tablets, and ordinary laptops. Normally I could use an asp.net function to tell, but the complication is that I want tablets to be treated as NOT being mobile devices. Any device with a screen diagonal greater than 7.5 inches would get the normal website, and any device with a screen dialog of less than this would get the mobile version of the site.

First I thought all I need to do is get the screen.width (I'm using JavaScript) and screen.height, apply the pythagorean theorem to get the length of the diagonal (in pixels) and then divide by pixels-per-inch. The issue is this: Is "pixels-per-inch" always 96 for every type of device? If not, I can't do this.

Thanks.

Upvotes: 2

Views: 601

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1075735

How do I know how many physical inches a device screen has?

You can't.

Is "pixels-per-inch" always 96 for every type of device?

No, not remotely. Not only do you have the issue of Retina displays, but if I have a notebook computer with a screen resolution of 1280x768, if the screen is 15.1" it's going to have a lower PPI than if the screen is 10.1".

Upvotes: 2

Related Questions