JOAOSANTACRUZ.COM

Detect onorientation change

Detect onorientation change on iOS device


						


window.onorientationchange = function() {

  var orientation = window.orientation;

  switch(orientation) {

    case 0:
        document.getElementById("currentOrientation").innerHTML="Now in portrait orientation";
        break; 

    case 90:
        document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the left";

        break;

    case -90: 
        document.getElementById("currentOrientation").innerHTML="Now in landscape orientation and turned to the right";
        break;

  }

}

Go Back