【问题标题】:When clicking on a button on IOS, iframe is not scrolling单击IOS上的按钮时,iframe不滚动
【发布时间】:2016-05-19 06:49:29
【问题描述】:

单击按钮时,我试图向下滚动到某个元素。但它不起作用。

我使用的方法是使用查询:

if (navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/)) {
    console.log('ios');

    $("html, body, .wrapper").animate({
        scrollTop: offset
    }, 500);
} else {

    $("html, body").animate({
        scrollTop: offset
    }, 500);
}

这些情况几乎相同,只是在某个地方阅读 animate 不适用于 ios 上的 html 和 body 标签。

但仍然无法使其工作。

这是里面:

$(".elem").click(function () {
    var offset = somenumber;
    //and the code above
});

【问题讨论】:

    标签: javascript ios iphone html scroll


    【解决方案1】:

    我修复的方法是,我使用了一个名为 postMessage 的 jquery 插件,这是一种跨域框架通信的好方法。

    http://benalman.com/projects/jquery-postmessage-plugin/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      • 2020-08-21
      • 1970-01-01
      • 1970-01-01
      • 2011-09-17
      相关资源
      最近更新 更多