Detecting orientation changes


show more Detecting orientation changes provides you with in-depth training on Developer. Taught by Joe Marini as part of the Mobile Web Design & Development Fundamentals show less
please wait ...

Detecting orientation changes

On the iPhone, your web pages can also detect changes in the device orientation, and you do that by responding to orientation events. The orientation events look like this. First, there is the onorientationchange, which is the event that's fired on the body element. You can assign a function to that handler to respond to changes in the orientation. You can also look at the orientation property on the window to see what the current orientation is. Now, it should be pointed out that window.orientation is read only.

You can't programmatically set the orientation and in the onorientationchange event, there is no way to prevent it from happening. The orientation is going to change, regardless of what your code tries to do. So let's take a look at example of handling this event to see how we can respond to device orientation changes in our code. So here I am in Xcode, and I've got my orientation_start example open, and this is just a very simple orientation example. So what I am ...

Detecting orientation changes
Video duration: 3m 58s 5h 47m Beginner

Viewers:

Detecting orientation changes provides you with in-depth training on Developer. Taught by Joe Marini as part of the Mobile Web Design & Development Fundamentals

Subjects:
Developer Web
Software:
HTML
Author:
please wait ...