/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
detectOrientation(); window.onorientationchange = detectOrientation; function detectOrientation(){ if(typeof window.onorientationchange != 'undefined'){ if ( orientation == 0 ) { //Do Something In Portrait Mode } else if ( orientation == 90 ) { //Do Something In Landscape Mode } else if ( orientation == -90 ) { //Do Something In Landscape Mode } else if ( orientation == 180 ) { //Do Something In Landscape Mode } } }
URL: http://www.devinrolsen.com/javascript-mobile-orientation-detection/