Handling Orientation Events jQuery

Device portrait/landscape orientation event
Value Description
0 Portrait orientation. This is the default value.
-90 Landscape orientation with the screen turned clockwise.
90 Landscape orientation with the screen turned counterclockwise.
180 Portrait orientation with the screen turned upside down. This value is currently not supported on iPhone.
<div id="output"></div>
function updateOrientation() {
     var displayStr = "Orientation : ";
     switch (window.orientation) {
         case 0:
             displayStr += "Portrait";
             break;
         case -90:
             displayStr += "Landscape (right, screen turned clockwise)";
             break;
         case 90:
             displayStr += "Landscape (left, screen turned counterclockwise)";
             break;
         case 180:
             displayStr += "Portrait (upside-down portrait)";
             break;
     }
     document.getElementById("output").innerHTML = displayStr;
 }
jQuery touch events
Handling Orientation Events jQuery Handling Orientation Events jQuery Reviewed by Bhaumik Patel on 8:05 PM Rating: 5