How do I correctly detect orientation change using Phonegap on iOS? How do I correctly detect orientation change using Phonegap on iOS? ios ios

How do I correctly detect orientation change using Phonegap on iOS?


This is what I do:

function doOnOrientationChange() {    switch(window.orientation) {        case -90: case 90:        alert('landscape');        break;       default:        alert('portrait');        break;     }}  window.addEventListener('orientationchange', doOnOrientationChange);  // Initial execution if neededdoOnOrientationChange();