Posted By

peterbelsky on 12/02/10


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bcmoney


Javascript Mobile Orientation Detection


 / Published in: JavaScript
 

URL: http://www.devinrolsen.com/javascript-mobile-orientation-detection/

  1. detectOrientation();
  2. window.onorientationchange = detectOrientation;
  3. function detectOrientation(){
  4. if(typeof window.onorientationchange != 'undefined'){
  5. if ( orientation == 0 ) {
  6. //Do Something In Portrait Mode
  7. }
  8. else if ( orientation == 90 ) {
  9. //Do Something In Landscape Mode
  10. }
  11. else if ( orientation == -90 ) {
  12. //Do Something In Landscape Mode
  13. }
  14. else if ( orientation == 180 ) {
  15. //Do Something In Landscape Mode
  16. }
  17. }
  18. }

Report this snippet  

You need to login to post a comment.