简体   繁体   English

Facebook 页面插件未显示在 HTML 页面中

[英]Facebook page plugin doesn't show in HTML page

I am trying to insert the facebook page plugin in html page and i am following this guide: https://developers.facebook.com/docs/plugins/page-plugin This is how i insert the code in the page:我正在尝试在 html 页面中插入 facebook 页面插件,我正在遵循本指南: https : //developers.facebook.com/docs/plugins/page-plugin这是我在页面中插入代码的方式:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>CNN</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

  </head>
  <body>
  <div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-page" data-href="https://www.facebook.com/cnn" data-width="300" data-height="200" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true" data-show-posts="false"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/cnn"><a href="https://www.facebook.com/cnn">CNN</a></blockquote></div></div>


  </body>
</html>

But the page plugin doesn't show.但是页面插件没有显示。 Any idea why it doesn't work?知道为什么它不起作用吗?

The problem was that i tested the script locally and that's why it didn't worked.问题是我在本地测试了脚本,这就是它不起作用的原因。 I uploaded the html page on a server and it worked.我在服务器上上传了 html 页面并且它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM