Is there a way to detect if the browser/device supports screen rotation, without having to wait for the orientationchange event? I'm not trying to detect the rotation itself, only if the browser or device supports it.
Asked
Active
Viewed 1,324 times
5
-
possible duplicate of [**Detect rotation of Android phone in the browser with javascript**](http://stackoverflow.com/questions/1649086/detect-rotation-of-android-phone-in-the-browser-with-javascript) – Nope Apr 12 '13 at 11:29
1 Answers
4
I think you can detect it like so:
if( 'onorientationchange' in window) { /* supported! */ }
However, I'm not sure if some browsers will support the event even though they never fire it.
Niet the Dark Absol
- 311,322
- 76
- 447
- 566
-
For thoroughness it might be worth checking to see if it holds a value for `window.orientation` too, but if the browser lies about supporting/firing `onorientationchange` there's a good chance it'll present a complete 'lie' I guess. – David Thomas Apr 12 '13 at 11:28
-
Thank you both for the answers. I guess this is the best possible solution, but it won't be triggered by some devices (according to this page: http://davidwalsh.name/orientation-change)... – jvilhena Apr 12 '13 at 11:51