orientationchange demo
by Prasad
HTML
<div data-role="page" id="page1">
<h1 id="orientation">orientationchange Not Supported on this Device.</h1>
</div>
JavaScript
// Bind an event to window.orientationchange that, when the device is turned,
// gets the orientation and displays it to on screen.
$( window ).on( "orientationchange", function( event ) {
/*$( "#orientation" ).text( "This device is in " + event.orientation + " mode!" );*/
if(event.orientation){
if(event.orientation == 'portrait'){
//do something
$( "#ProductNameDisplay4103" ).text( "Orientation changed, This device is in " + event.orientation + " mode!" );
}
else if(event.orientation == 'landscape') {
//do something
$( "#ProductNameDisplay4103" ).text( "Orientation changed, This device is in " + event.orientation + " mode!" );
}
}
});
// You can also manually force this event to fire.
$( window ).orientationchange();