使用JQuery更改Facebook元标记内容属性 [英] Changing Facebook meta tag Content Attribute using JQuery

查看:75
本文介绍了使用JQuery更改Facebook元标记内容属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使用JQuery来替换我的Facebook元标签的内容属性。

I want to know how can I use JQuery in order to replace the content attribute of my Facebook meta tags.

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

I searched StackOverflow and what I've found was this example:

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

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

In my code I have the following meta tags:

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

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

When I run the function that should change the content for the 'title' and 'url' variables, the change doesn't take place. The same values for the 'content' still remains the same.

我想知道如何使用JQuery来改变Facebook元标记的价值。

I want to know how, if it's possible, to use JQuery to change the value of Facebook's meta tags.

推荐答案

绝对有可能使用jQuery更改元标记,但我不认为这将完成你想要的元标签由FB刮刀拉出。 FB刮刀出来并刮擦您的页面以阅读元标签。

It is definitely possible to change meta tags using jQuery, but I don't think that's going to accomplish what you want since the meta tags are pulled by the FB scraper. The FB scraper goes out and scrapes your page to read the meta tags.


编辑元标签

Editing Meta Tags

您可以通过更新页面的
标签来更新页面的属性。请注意,og:title和og:type最初只能编辑
- 在您的页面收到50个喜欢的标题变得固定后,
,并且在您的页面收到10,000个类型变为固定后。
这些属性是固定的,以避免令人惊讶的用户已经喜欢
的页面。达到这些限制
之后更改标题或类型标签不会执行任何操作,您的页面保留原始标题和
类型。

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.

反映在Facebook上,您必须强制您的页面
被刮。当页面的管理员点击
喜欢按钮或网址输入到Facebook网址
Linter时,页面将被删除。您可以通过编程方式强制您的页面被
删除。例如...

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/

这篇关于使用JQuery更改Facebook元标记内容属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆