开发者

Jquery mobile orientation change returns opposite value

I am currently working on a mobile website using jquery mobile and I encountered problem in detecting orientation change. My mobile website detects the orientation as "landscape" when in portrait mode and vice versa when test开发者_如何学Cing on my Samsung Galaxy. However, working properly on iphone n HTC Desire. I did find in some forums that described that as Android bug and someone used setTimeOut to tackle it. But I can't solve the problem using that. Not sure if it's my syntax error or not. Can someone kindly enlighten me? Thanks in advance.

Sample code will be much appreciated.

Here is my current code:

    $(document).ready(function() {


    $(window).bind("orientationchange", function (event) {

            setTimeout(detectOri(event),100);

    });

    function detectOri(event)
    {

        alert(event.orientation);

        if(event.orientation == 'portrait')
           {

              //load portrait mode page
           }

           else if(event.orientation == 'landscape')
           {

             //load landscape mode page
           }

    }

});


you shouldn't be using DOM ready

use pageinit


change setTimeout(detectOri(event),100); for this:

setTimeout(detectOri,1000);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜