javascriptscreen-rotation

Detect if browser/device supports screen rotation


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.


Solution

  • 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.