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
Share
Apple has posted sample code demonstrating how to handle iPhone or iPod touch orientation events through JavaScript, HTML, and CSS....
Add a Comment
You can also do the same thing with Jiggy (http://www.jiggyapp.com). It lets your application receive accelerometer events, among many other cool things.
December 22 2007 at 12:02 PM Report abuse Permalink rate up rate down Replyhttp://ripdvdtomp4.tumblr.com/
December 21 2007 at 5:02 AM Report abuse Permalink rate up rate down ReplyI don't understand how this is new? Didn't Apple post some kind of web API when the iPhone was launched?
December 21 2007 at 2:33 AM Report abuse Permalink rate up rate down ReplyUsing this code, my friend Nathan and I put together this nice iPhone Snow Globe.
http://www.iPhoneSnowGlobe.com
Happy Holidays!
Justin
It might be helpful to know that it maintains its previous orientation when navigating away and then back, as in, if I click one of the links in Portrait mode, turn the phone to landscape, and push 'Back', the first page still thinks it's in portrait.
December 20 2007 at 4:56 PM Report abuse Permalink rate up rate down Replymacsaber has been out for a while, search for isaber
Nice precursor to the SDK hopefully.
December 20 2007 at 3:49 PM Report abuse Permalink rate up rate down Replycool... but no detection for upside-down (home button on the top)?
December 20 2007 at 3:35 PM Report abuse Permalink rate up rate down ReplySo how long before we have an iPhone version of MacSaber?
December 20 2007 at 3:25 PM Report abuse Permalink rate up rate down ReplyNot anytime soon. This is literally ONLY to convey the information of whether the screen is held portrait or landscape.
December 20 2007 at 3:48 PM Report abuse Permalink rate up rate down ReplyHot Apps on TUAW
Deals of the Day
more deals- Refurb Apple MacBook Air Laptops: 12" 64GB SSD for $699 + free shipping
- JVC Motion Sensing Clock Radio with Dual iPod Docks for $55 + free shipping
- Apple iPhone Headset with Mic for $4 + $2 s&h
- miFrame Picture Frame Dock for iPad for $64 + $8 s&h
- Refurb Apple iPod nano 8GB MP3 Player for $99 + free shipping, 16GB for $119
- Hannspree Apple-Shaped 28" 1080p LCD HDTV for $270 + free shipping
Software Updates
more updates- EFI Firmware Update brings Lion Internet Recovery to 2010-model Macs
- OS X Lion 10.7.3 released with Safari 5.1.3, Wi-Fi bug fix
- Aperture updated to 3.2.2, addresses Photo Stream issue
- Apple updates Keynote to address Lion issues
- Google Search app gets new look on iPad
- Apple releases Apple TV Software Update 4.4.3



10 Comments