微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用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.jb51.cc/jquery/180999.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐