1

我目前正在使用 jquery mobile 开发移动网站,但在检测方向变化时遇到了问题。我的移动网站在纵向模式下将方向检测为“横向”,在我的三星 Galaxy 上进行测试时反之亦然。但是,在 iphone n HTC Desire 上正常工作。我确实在一些论坛中发现了将其描述为 Android 错误,并且有人使用 setTimeOut 来解决它。但是我无法使用它来解决问题。不确定这是否是我的语法错误。有人可以启发我吗?提前致谢。

示例代码将不胜感激。

这是我当前的代码:

    $(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
           }

    }

});
4

2 回答 2

0

你不应该准备好使用 DOM

使用页面初始化

于 2011-11-15T03:19:04.010 回答
0

setTimeout(detectOri(event),100);为此改变:

setTimeout(detectOri,1000);
于 2012-05-03T17:39:45.747 回答