Facebook聊天插件自动滚动到顶部

Facebook聊天插件自动滚动到顶部

本文介绍了加载时,Facebook聊天插件自动滚动到顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在由OpenCart支持的网站上使用8.0版的Facebook Chat插件(尽管我怀疑它会在任何CMS中发生).聊天插件完全加载需要花费几秒钟,并且图标会显示在页面的右下角.

I am using Facebook Chat plugin version 8.0 on a site powered by OpenCart (though I suspect it will happen in any CMS). It always takes a few seconds for the chat plugin to fully load and the icon to appear in the lower right corner of the page.

但是,显示图标时,页面立即滚动到顶部.因此,如果用户已经开始向下滚动,则该用户将被中断并重置页面.

However, when the icon is displayed, the page immediately scrolls to the top. So if a user already started scrolling down, he is interrupted and the page is reset.

有什么想法会导致这种情况,以及如何防止这种情况发生?

Any idea what might be causing this and how to prevent it?

这是我的代码(Facebook在设置"->消息传递"->向您的网站添加Messenger"中自动生成的原始代码):

This is my code (vanilla code auto generated by Facebook in Settings->Messaging->Add Messenger to your website):

<script>

        FB.init({
            xfbml            : true,
            version          : 'v8.0'
          });
        };

        (function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) return;
          js = d.createElement(s); js.id = id;
          js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
          fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));

</script>

        <!-- Your Chat Plugin code -->
        <div class="fb-customerchat"
            greeting_dialog_display="hide"
            attribution=setup_tool
            page_id="xxxxxxxxxxxxxxxx"
            theme_color="#67b868">
        </div>

推荐答案

该错误当前正在此处跟踪: https://developers.facebook.com/support/bugs/619023102320436/.

The bug is currently being tracked here: https://developers.facebook.com/support/bugs/619023102320436/.

目前,我已经实现了以下hack(在插件的加载时间附近):

At the moment I have implemented the following hack (around the load time of the plugin):

var originalScrollTo = window.scrollTo;
window.scrollTo = function() {};

setTimeout(function() {
 window.scrollTo = originalScrollTo;
}, 5000);

这篇关于加载时,Facebook聊天插件自动滚动到顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:21