本文介绍了Facebook建议忽略og:title,直到页面刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Facebook推荐"按钮的典型HTML5实现:

I have the typical HTML5 implementation of the Facebook recommend button:

<div id="fb-root"></div>
<script type="javascript">
(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    <? if ( $current_language == 'en' ): ?>
        js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
    <? else: ?>
        js.src = "//connect.facebook.net/fr_CA/all.js#xfbml=1";
    <? endif; ?>
    fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
</script>

<div class="share_button facebook" id="facebook">
    <div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="false" data-action="recommend"></div>
</div>

我第一次单击它时,弹出预览框不会显示标题"或描述".我在页面顶部有以下信息: 测试

The first time I click it, the popup preview box does not display the Title or Description. I have the following info at the top of the page: Test

<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<meta name="description" content="Test website." />
<meta name="keywords" content="test whatever" />
<meta property="og:title" name="Show this!" content="Show this!" />

如果我离开该页面,请从Facebook上不推荐该页面,然后返回同一页面,然后再次按推荐",然后出现标题和说明.该页面显示了数千个db条目之一,因此需要解决此问题.我尝试将js函数放入jQuery(document).ready(function()-不走运.我尝试将其移至页面底部-不走运.有人可以帮助我吗?

If I leave the page, unrecommend the page from Facebook and return to the same page and press Recommend again, the title and description then appear. The page shows one of thousands of db entries so the problem needs to be fixed. I have tried putting the js function in jQuery(document).ready(function() - no luck. I tried moving it to the bottom of the page - no luck. Can someone help me?

推荐答案

在您提供的示例中,您缺少一些必需的OG标签,例如URL和图像.另外,您的head标签上是否有前缀信息?

From the example you gave, you are missing some required OG tags such as URL and image. Also, do you have the prefix info on your head tag?

<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# myspecialapp: http://ogp.me/ns/fb/myspecialapp#">

这篇关于Facebook建议忽略og:title,直到页面刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:23