Latest web development tutorials

jQuery Mobile orientationchange event

jQuery Mobile Events jQuery Mobile Events

Examples

Flip mobile user equipment chamber pop some text message:

$(window).on("orientationchange",function(){
alert("方向已改变!");
});

try it"

Definition and Usage

Orientationchange event-triggered events (ie changes in direction) in a horizontal or vertical flip user device.

Note: If you want to see the effect orientationchange events, the user must use a mobile device to view the site or mobile emulator instance.


grammar

$(window).on("orientationchange",function(event){...})

参数 描述
function(event) 必须。指定 orientationchange 事件触发后执行的函数。

要确定设备按哪个方向旋转,您可以访问方向属性 orientation ,属性值可以是 "portrait(纵向)" 或者 "landscape(横向)"。

  • Portrait = 设备在纵向位置旋转
  • Landscape = 设备在横向位置旋转


Examples s

More examples

Event objects
Use of mobile devices return direction event.orientation.

Window object
Use window.orientation Settings "portrait (vertical)" and "landscape (horizontal)" between different style properties.


jQuery Mobile Events jQuery Mobile Events