Skip to content

Instantly share code, notes, and snippets.

@stefano-bortolotti
Last active October 6, 2015 13:47
Show Gist options
  • Save stefano-bortolotti/3002454 to your computer and use it in GitHub Desktop.
Save stefano-bortolotti/3002454 to your computer and use it in GitHub Desktop.
JS: detect screen orientation
switch (window.orientation) {
case 90:
case -90: document.body.setAttribute('landscape', 'landscape');
break;
case 0:
case 180: document.body.removeAttribute('landscape');
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment