I'm trying to figure out how to change an embedded web page when the user rotates their phone from portrait to landscape mode - basically to load a view that is better suited to the wider screen format. Is this possible to do without calling a new page from the server, i.e. to drive it from within CSS/Javascript itself?
Thanks!
You can use the
window.orientation
property. Its value is the degree that the current mode of view is used. Here is a brief example:You can use this function on this event:
Hope that helps!
Safari Mobile supports orientation events.
Best not to set the
onorientationchange
property directly. Instead use the following:I can't believe no one talked about the css ruling:
From: Safari Web Content Guide
The Safari mobile browser has support for the
orientationchange
event as well as theorientation
property on the window, so you can do something like:I would add the upside-down because the iPad human interface guidelines say you should support all orientations, so I would expect Safari on the iPad (and possibly future iPhone versions) to support it.