Detect rotation of Android phone in the browser with JavaScript

I know that in Safari on an iPhone you can detect the screen’s orientation and change of orientation by listening for the onorientationchange event and querying window.orientation for the angle.

Is this possible in the browser on Android phones?

To be clear, I am asking whether the rotation of an Android device can be detected by JavaScript running on a standard web page. It is possible on an iPhone, and I wondered whether it could be done for Android phones.

12 Answers
12

Leave a Comment