iOS设备,fixed布局出问题

    window.deviceId = '{{$deviceId}}';
    window.iOS = navigator.userAgent.match(/(iPad|iPhone|iPod)/g) ? true : false;
    if( iOS ){
      iOSversion = ( !!window.history && !!window.history.pushState ? '4+' : '4-' );
      if( !!window.matchMedia ){ iOSversion = '5+'; }
    }
    window.getViewport = function() {    // Note viewport sizing broken in Android 2.x see http://stackoverflow.com/questions/6601881/problem-with-meta-viewport-and-android
      var viewport = {
              left: window.pageXOffset,   // http://www.quirksmode.org/mobile/tableViewport.html
              top: window.pageYOffset,
              width: window.innerWidth || documentElement.clientWidth,
              height: window.innerHeight || documentElement.clientHeight
      };
      return viewport;
    }

 

在android机器上可以正常提升上来,但是在iOS机器上会出现问题。

在iOS机器上,不通过bottom来始终居底部,而是通过计算top的位置再通过scrollTo来调整位置。

 

    window.timeDelay = 300;
    setInterval(function () {
      window.scrollTo(0, 0);
    }, timeDelay);

  

posted @ 2015-04-14 22:08  wangchao719  阅读(1134)  评论(0编辑  收藏  举报