As the height and width of the browser is affected on changing the orientation of the iPhone, Safari provides a Javascript event called onorientationchange on the tag which notifies whenever you tilt the orientation. Safari also provides a property called window.orientation which provides the angle of tilt with 0° being the bottom of the iPhone.
So the code would like something like this in HTML
Developing can be most effective if there is a good ability to know of problems in the developed content. iPhone allows a user to view problems in HTML, CSS, Javascript on web pages by enabling the debug console on Safari.
Enable Debug Console
Debug Console in Action
After enabling the console, going to any web page automatically adds a 48 pixel bar summarizing the debug messages.
Its nice that even tips are presented which goes on to show the effort put into this functionality - where just showing errors is cause for celebration.