orientation

このエントリーをはてなブックマークに追加

window.orientationは現在のデバイスの向きが格納されたプロパティです。

portrait(縦向き)時には0を、landscape(横向き)時には90もしくは-90といった値を取得できます。

window.addEventListener("orientationchange",function(){
   if(window.orientation===0){
      alert("portrait");
   }else{
      alert("landscape");
   }
},false);

このプロパティはよくorientationchangeイベントと一緒に利用されます。

登録日 : 2012年12月27日 最終更新日 : 2012年12月27日

同じカテゴリー(Window)のエントリー

検索

スポンサードリンク

バージョン

リファレンス