Detecting Mobile Screen Size

$("#contentBody").width(screen.width).height(screen.height);

In today’s mobile world, the fact that a user is on a mobile device is no longer the critical question. The new critical question is this: How much screen space do users have to work? You need to check on the device’s screen size. Does it have a 3-inch, 4-inch, or 11-inch screen? There is a big difference. To get the screen size, use screen.height and screen.width in JavaScript and then adjust your pages dynamically to support that size.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.