Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 234
jvilhena Avatar asked Oct 04 '22 10:10

jvilhena


1 Answers

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.

like image 193
Niet the Dark Absol Avatar answered Oct 10 '22 03:10

Niet the Dark Absol