0

What would be the best approach to detect whenever the user changes the orientation of his phone. I am talking for a mobile site not for a native app.

Thanks,

silkAdmin
  • 4,440
  • 9
  • 50
  • 82

1 Answers1

1
window.addEventListener('onorientationchange', function () {
    if (window.orientation == -90) {
        //do stuff
    }
    if (window.orientation == 90) {
        //do stuff
    }
    if (window.orientation == 0) {
        //do stuff
    }
}, true);
Mild Fuzz
  • 27,845
  • 29
  • 97
  • 148