Orientation change in phonegap
<pre><code>window.onresize = function(){ updateOrientation(e); }
    function updateOrientation(e) {
        alert("hey");

        deviceWidth = $('body').width();
        if (deviceWidth == 320) {
            currentOrientation = "portrait";
        }
        else if (deviceWidth == 480) {
            currentOrientation = "landscape";
        }

        // fire a function that checks the orientation every x milliseconds
        setInterval(checkOrientation, 500);

        // check orientation
        function checkOrientation() {
            deviceWidth = $('body').width();
            if (deviceWidth &gt;= '1200') {
                newOrientation = "portrait";
            }
            else if (deviceWidth &lt;= '900') {
                newOrientation = "landscape";
            }
            // if orientation changed since last check, fire either the portrait or landscape function
            if (newOrientation != currentOrientation) {
                if (newOrientation == "portrait") {
                    changedToPortrait();
                }
                else if (newOrientation == "landscape") {
                    changedToLandscape();
                }
                currentOrientation = newOrientation;
            }
        }

        // landscape stuff
        function changedToLandscape() {
            alert('Orientation has changed to Landscape!');
        }

        // portrait stuff
        function changedToPortrait() {
            alert('Orientation has changed to Portrait!');
        }
    }
</code></pre>

<p>i am using this to detect the orientation change in android tablet using phonegap. somehow the code is not working. any suggestions?  It is unable to generate an event for orientation change am guessing.</p>
