Skip to content

Instantly share code, notes, and snippets.

@KnightAlex
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KnightAlex/6ef4ff6754771de2a7dc to your computer and use it in GitHub Desktop.
Save KnightAlex/6ef4ff6754771de2a7dc to your computer and use it in GitHub Desktop.
Detect device rotation and reload page
// RELOADS WEBPAGE WHEN MOBILE ORIENTATION CHANGES
window.onorientationchange = function() {
var orientation = window.orientation;
switch(orientation) {
case 0: window.location.reload();
break;
case 90: window.location.reload();
break;
case -90: window.location.reload();
break;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment