views:

488

answers:

1

I'm building an app in the browser for the iPad and was wondering if it's possible to lock the orientation of the viewport? I've checked apple's documentation and the only thing I've found says orientation is read only : http://developer.apple.com/safari/library/documentation/DataManagement/Reference/DOMWindowAdditionsReference/DOMWindowAdditions/DOMWindowAdditions.html#//apple_ref/javascript/instp/DOMWindow/orientation

I'm thinking this means that there is no way to lock the orientation in the browser. Anyone got any ideas?

Thanks,

Joe

+1  A: 

No. I guess this would appear too restrictive to the user, so you can only detect UI orientation. The only way to lock the orientation would be the exterior switch on the side of the device.

See this answer for code to detect it. You could also just use window.orientation to get it.

For my webapps, I simply have a popover-view that alerts the user to rotate their device when its orientation is not desirable. You might even consider two UI setups for different orientations for a more customizable experience.

pop850