jQuery Mobile orientationchange 事件

2018-09-13 23:48 更新

jQuery Mobile orientationchange 事件

jQuery Mobile 事件 jQuery Mobile 事件

實例

在用戶翻轉(zhuǎn)移動設(shè)備室彈出一些文字信息:

$(window).on("orientationchange",function(){
? alert("The orientation has changed!");
});

嘗試一下 ?

定義和用法

orientationchange 事件是在用戶水平或者垂直翻轉(zhuǎn)設(shè)備(即方向發(fā)生變化)時觸發(fā)的事件。

注意:如果要查看 orientationchange 事件的效果, 用戶必須使用移動設(shè)備或者移動模擬器來查看本站實例。


語法

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

參數(shù) 描述
function(event) 必須。指定 orientationchange 事件觸發(fā)后執(zhí)行的函數(shù)。

要確定設(shè)備按哪個方向旋轉(zhuǎn),您可以訪問方向?qū)傩?orientation ,屬性值可以是 "portrait(縱向)" 或者 "landscape(橫向)"。

  • Portrait = 設(shè)備在縱向位置旋轉(zhuǎn)
  • Landscape = 設(shè)備在橫向位置旋轉(zhuǎn)


實例s

更多實例

事件對象
使用 event.orientation 返回移動設(shè)備的方向。

窗口對象
使用 window.orientation 屬性設(shè)置"portrait(縱向)" 和 "landscape(橫向)"間不同的樣式。


jQuery Mobile 事件 jQuery Mobile 事件

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號