单击IOS上的按钮时,iframe不滚动

Posted

技术标签:

【中文标题】单击IOS上的按钮时,iframe不滚动【英文标题】:When clicking on a button on IOS, iframe is not scrolling 【发布时间】: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
);

【问题讨论】:

【参考方案1】:

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

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

【讨论】:

以上是关于单击IOS上的按钮时,iframe不滚动的主要内容,如果未能解决你的问题,请参考以下文章