Skip to content

Instantly share code, notes, and snippets.

@stefano-bortolotti
Created March 12, 2014 16:27
Show Gist options
  • Save stefano-bortolotti/9510619 to your computer and use it in GitHub Desktop.
Save stefano-bortolotti/9510619 to your computer and use it in GitHub Desktop.
Set screen orientation to the body tag
function _getScreenOrientation() {
/*
returns screen orientation(landscape|portrait) and
set the attribute on the body "data-landscape[true|false]"
*/
if ( window.orientation == ( -90 || 180 ) ) {
document.body.setAttribute('data-landscape', 'true');
return 'landscape';
}
else {
document.body.setAttribute('data-landscape', 'false');
return 'portrait';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment