This is one situation which baffles me sometimes and I face this one regularly while developing mobile web apps – I want to know whether the device is held in portrait or landscape mode when the page first loads and then based on the result I change the look n feel. Remember landscape mode of the device is more wider and the screen width increases, so does the viewport width so you have to adjust your page layout accordingly. For the full post download this file or visit the actual blog post link: http://jbkflex.wordpress.com/2012/02/27/how-to-detect-the-orientation-of-device-at-page-load-iphone/