JavaScript
Article
By Sam Deering

JavaScript Capture IOS7 iPad Screen Orientation Change

By Sam Deering
Last chance to win! You'll get a... FREE 6-Month Subscription to SitePoint Premium Plus you'll go in the draw to WIN a new Macbook SitePoint 2017 Survey Yes, let's Do this It only takes 5 min

Code snippet to capture ipad device change (IOS7) tested.

--ADVERTISEMENT--

jQuery(document).ready(function($) {
//capture ipad device change (IOS7) tested.
function doOnOrientationChange()
{
  // alert(window.orientation);
  switch(window.orientation)
  {
    case 0:
    case 90:
      alert('portrait');
      $('html').removeClass('landscape').addClass('portrait');
      break;
    case -90:
      alert('landscape');
      $('html').removeClass('portrait').addClass('landscape');
      break;
    default:
      break;
  }
}
});
Login or Create Account to Comment
Login Create Account
Recommended
Sponsors
Get the most important and interesting stories in tech. Straight to your inbox, daily.Is it good?