Just started a mobile web app using jQuery Mobile. When I rotate the device to landscape-mode and then back to portrait, the view gets stuck in landscape-mode. Do I manually need to refresh the view based on the event or…? I’m currently testing on an iPhone.
/Rasmus
If you have not yet tried different
viewporttags, try this one out:The important part as far as your question is concerned is
width=device-width.–> UPDATE <–
Here is a JavaScript example that deals with Mobile Safari not updating the viewport width/height values on orientationchange:
The code above checks the
navigator.userAgentstring to see if the device is an iPhone. It then binds an event handler to the orientationchange event that detects the orientation of the device and updates the viewport tag to use the proper dimensions depending on the orientation. Notice how theheightis set to thedevice-widthwhen the device is in landscape orientation.