Advertisement

iPhone Orientation: Apple Sample Code

Apple has posted sample code demonstrating how to handle iPhone or iPod touch orientation events through JavaScript, HTML, and CSS. Whenever an iPhone rotates, it triggers orientation events that you can catch in Mobile Safari. Apple provides a sample iPhoneOrientation.js file that implements a typical handler, window.onorientationchange. CSS attributes can dynamically change how the webpage appears.

I loaded a copy of the sample over at my website. If you'd like to give it a try on your iPhone, navigate here.

Thanks, syd