Facebook 元标记不适用于 AJAX 网站

发布于 2024-12-11 16:25:37 字数 328 浏览 2 评论 0原文

我有一个 100% ajax web 应用程序,但有以下问题。 我的网站生成动态内容,每个 ajax“页面”都有一个“赞”按钮 动态生成的。需要明确的是,他的链接是“...#subpage”,用户可以将“like”放在 “...#subpage”。不过,我希望能够预览该内容。

我已经放置了适当的元标记(og:image、og:url 等)但是,在 facebook 链接调试器 (http://developers.facebook.com/tools/debug) 它总是说标签处于初始状态(就像在纯 html 页面中一样,没有 ajax)。

所以问题是,如何使元标签动态地用于 Facebook 链接

I have a 100% ajax webapp and I have the following problem.
My site generates dynamic content, and I have a like button for each ajax "page"
generated dynamically. To be clear, he links are "...#subpage", and a user can put like on
"...#subpage". However, I would like a preview of that content to be available.

I have put the apropriate meta tags (og:image, og:url, etc.) However, in the
facebook link debugger (http://developers.facebook.com/tools/debug) It always says that the tags are in their initial state (as in just the plain html page, no ajax).

So question is, how to make the meta tags work dyamically for facebook links

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

全部不再 2024-12-18 16:25:37

最好为页面提供自己的 URL。您可以使用 .htaccess 等服务器端方法将 http://yourdomain.com/birds/bees 等 URL 重定向到 http://yourdomain.com ?page=birds&subpage=bees。这样您的内容就变得可搜索、可访问和可添加书签。

您可以使用 HTML5 历史记录 API (http://html5demos.com/history) 来更新地址栏当前 URL,无需重新加载页面。您还可以将事件附加到后退按钮,这使您的网站更加用户友好。

当您更新地址栏时,您也可以使用 Javascript 来更新元标记,因此 Facebook 点赞按钮将点赞“正确”页面。

HTML5 History API 适用于所有现代浏览器,Internet Explorer 是唯一不受支持的浏览器。

It's best to actually give the pages their own URL. You can use server side methods like .htaccess to redirect a URL like http://yourdomain.com/birds/bees to http://yourdomain.com?page=birds&subpage=bees. That way your content becomes searchable, accessible and bookmarkable.

You can use the HTML5 history API (http://html5demos.com/history) to update the address bar with the current URL without reloading the page. You can also attach an event to the back button, which makes your site even more user-friendly.

When you update the address bar, you can use Javascript to update the meta tags too, so the Facebook like button will like the 'correct' page.

The HTML5 History API works in all modern browsers, Internet Explorer is the only unsupported browser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文