Skip to content

Instantly share code, notes, and snippets.

@mynameispj
Last active September 3, 2020 19:39
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mynameispj/5234017 to your computer and use it in GitHub Desktop.
Save mynameispj/5234017 to your computer and use it in GitHub Desktop.
jQuery event that fires when the orientation (portrait, landscape) of a mobile device changes
window.addEventListener("orientationchange", function() {
alert(window.orientation);
//do whatever you want on orientation change here
}, false);
@Shahor
Copy link

Shahor commented Apr 26, 2015

Just came here to say there is no jQuery usage whatsoever in this snippet. I have no idea why you talk about jQuery here.

@stuff
Copy link

stuff commented Apr 26, 2015

agreed :p

@biesior
Copy link

biesior commented Sep 3, 2020

agreed, also keep in mind that you have 3-rd orientation to handle: square

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment