简体   繁体   English

在Ajax页面上使用addThis时使用Facebook(无标题)

[英]Facebook (no title) when using addThis on Ajax pages

Im using addThis for create share button on a project, email and twitter work fine but Linkedin and Facebook do not work. 我使用addThis在项目上创建共享按钮,电子邮件和推特工作正常,但Linkedin和Facebook无法正常工作。 I understand they need opengraph to work but what if your content is javascript driven? 我了解他们需要opengraph才能正常工作,但是如果您的内容是JavaScript驱动的,该怎么办? At the moment the Facebook popup simply shows (no title).. Has anyone else been able to get facebook share to work for addThis on AJAX pages? 目前,Facebook弹出窗口仅显示(无标题)。还有其他人能够在AJAX页面上获取Facebook共享以进行addThis吗?

Thank you in advance. 先感谢您。

This is the script Im using on my page at the moment. 这是我目前在页面上使用的脚本。

 <!--- share --->
                <div class="share-buttons" id="toolbox-5"></div>
                <script type="text/javascript">
                var tbx = document.getElementById("toolbox-5"),
                    svcs = {
                        email: 'Email',
                        print: 'Print',
                        // facebook: 'Facebook',
                        twitter: 'twitter',
                        // linkedin: 'linkedin'
                    };

                for (var s in svcs) {
                    tbx.innerHTML += '<a class="addthis_button_'+s+'">'+svcs[s]+'</a>';
                }
                addthis.toolbox("#toolbox-5"
                    , {}
                    , {url: "www.urlofthing.com"
                    , title: "title of thing"});
                // );
                </script>
                <!--- share --->

An example of the URL my application uses.. 我的应用程序使用的URL示例。

http:domain.com/dir/section/#!/3/1017/

After the new content has been loaded, try forcing the url via the specific AddThis method: 加载新内容后,请尝试通过特定的AddThis方法强制使用url:

addthis.update('share', 'url', window.location.href); // re-parse the url
addthis.ready(); // re-render the buttons.

This has been a good starting point for me to solve the same problem you describe: 对于我解决您描述的相同问题,这是一个很好的起点:

AddThis buttons wont update to include fragment (#Hash Tag) AddThis按钮将不会更新以包含片段(#Hash标签)

Bye! 再见!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM