jQuery Mobile orientationchangeEvent
Examples
When the user rotates the mobile device, pop up some text information:
$(window).on("orientationchange",function(){
alert("Orientation changed!");
});
alert("Orientation changed!");
});
Try it Yourself »
Definition and Usage
The orientationchange event is triggered when the user rotates the device horizontally or vertically (i.e., when the orientation changes).
Note:To see the effect of the orientationchange event, users must use a mobile device or a mobile emulator to view the examples on this site.
Syntax
$(window).on("orientationchange",function(event){...})
| Parameter | Description |
|---|---|
| function(event) | Required. Specifies the function to execute after the orientationchange event is triggered. To determine which direction the device is rotated, you can access the orientation property, whose value can be "portrait" or "landscape".
|

More Examples
Event Object
Use event.orientation to return the orientation of the mobile device.
Window Object
Use the window.orientation property to set different styles between "portrait" and "landscape".
Other Extensions
jQuery Mobile Events