I stumbled on that by accident. One of my javascript-variables was called orientation and was not correctly used on the iPad’s Safari. After looking at its content, I found out that you can detect the...
You can use javascript in an event handler, loop, or whatever by accessingwindow.orientation (or only orientation).
Here’s an example on how to detect the current orientation of the iPad device either by pressing a button or when the orientation changes, using an event called onOrientationChange:
<button onclick="detectIPadOrientation();">What's my Orientation?</button> <script type="text/javascript"> window.onorientationchange = detectIPadOrientation; function detectIPadOrientation () { if ( orientation == 0 ) { alert ('Portrait Mode, Home Button bottom'); } else if ( orientation == 90 ) { alert ('Landscape Mode, Home Button right'); } else if ( orientation == -90 ) { alert ('Landscape Mode, Home Button left'); } else if ( orientation == 180 ) { alert ('Portrait Mode, Home Button top'); } } </script>
You can also use CSS Stylesheets using the media definition:
<link rel="stylesheet" media="all and (orientation:portrait)" href="portrait.css"> <link rel="stylesheet" media="all and (orientation:landscape)" href="landscape.css">
















