使用JQuery更改Facebook元标记内容属性

前端之家收集整理的这篇文章主要介绍了使用JQuery更改Facebook元标记内容属性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想知道如何使用JQuery来替换我的Facebook元标记内容属性.

搜索了StackOverflow,我发现的是这个例子:

$("Meta[property=og:title]").attr("content",title);
$("Meta[property=og:url]").attr("content",url);

在我的代码中,我有以下元标记

<Meta property="og:title" content="some content"/>
<Meta property="og:url" content="some content"/>
<Meta property="og:site_name" content="some content"/>

当我运行应该更改’title’和’url’变量的内容函数时,不会发生更改. “内容”的相同值仍然保持不变.

我想知道如果可能的话,如何使用JQuery来改变Facebook元标记的价值.

解决方法

绝对可以使用jQuery更改元标记,但我认为这不会达到你想要的,因为元标记是由FB scraper提取的. FB刮刀熄灭并刮擦您的页面以读取元标记.

Editing Meta Tags

You can update the attributes of your page by updating your page’s
tags. Note that og:title and og:type are only editable
initially – after your page receives 50 likes the title becomes fixed,
and after your page receives 10,000 likes the type becomes fixed.
These properties are fixed to avoid surprising users who have liked
the page already. Changing the title or type tags after these limits
are reached does nothing,your page retains the original title and
type.

For the changes to be reflected on Facebook,you must force your page
to be scraped. The page is scraped when an admin for the page clicks
the Like button or when the URL is entered into the Facebook URL
Linter. You can programmatically force your page to be scraped by
cURL’ing the linter. For example …

https://developers.facebook.com/docs/opengraph/

原文链接:https://www.f2er.com/jquery/180999.html

猜你在找的jQuery相关文章