I need to find the device-width of the mobile device.
Although we can specify the content
<meta name="viewport" content="width=device-width; user-scalable=no" />
But i need to programmatically obtain the device width to compute some logic in my application. How can I get the device width?
The
viewportdimensions can be gathered via thewindowobject:Though you won’t always get perfect results, different devices behave differently and this gives the
viewportdimensions, not the screen dimensions.Alternatively you could check the width of a
data-role="page"element to find thedevice-width(since it’s set to100%of thedevice-width):