簡體   English   中英

將Facebook頁面嵌入網站

[英]Embed Facebook page into site

回到另一個問題,但是這次與SQL無關!

我正在創建一個網站,以允許用戶注冊並發布帖子。 當他們注冊時,他們可以輸入Facebook頁面名稱,而我希望能夠將頁面嵌入到他們的個人資料頁面中,以便當人們查看其個人資料時,Facebook頁面將顯示在一個小窗口中。 我去了Facebook的Page Plugin頁面,但是我不確定這是否是實現我想要的最好的方法。 我已經做了很多搜索,但是沒有任何運氣。

我試圖在站點中僅放置一個頁面的代碼,但是卻一直空白。 這是我從頁面插件站點獲得的:

<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 = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.12';
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-page" data-href="https://www.facebook.com/KeenesListcom-126649220715963/" data-tabs="timeline" data-small-header="false" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true"><blockquote cite="https://www.facebook.com/KeenesListcom-126649220715963/" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/KeenesListcom-126649220715963/">KeenesList.com</a></blockquote></div>

任何幫助表示贊賞。

編輯

好的,問題實際上出在Google Chrome。 我在IE 11和Firefox中進行了嘗試,並且頁面加載正常。 仍然需要弄清楚為什么它無法在Chrome中加載。

第二次編輯

好的,這很奇怪。 我有3個使用iframe顯示的不同項目。 Facebook頁面,Strava活動日志和Trailforks活動日志。 Strava和Trailforks項顯示正常,但Facebook Page出於某種原因未顯示。 這僅在Chrome中有效,Facebook在Firefox和IE中可以正常工作。 這是我的代碼:

<iframe src=https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Fmountainbikingintheus%2F&tabs=timeline&width=350&height=400&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId width=350 height=400 style=border:none;overflow:hidden scrolling=no frameborder=0 allowTransparency=true></iframe>

<iframe height=160 width=300 frameborder=0 allowtransparency=true scrolling=no src=https://www.strava.com/athletes/21039441/activity-summary/947ebf6e987358db8c8785041ad46b5a4d4ea7c5></iframe>

<iframe width=400 height=277 frameborder=0 src=https://www.trailforks.com/widgets/ridelogs/?userid=1306231&w=400px&h=277px&map=0&stats=1></iframe>

第3次編輯:完整代碼

這是我完整的代碼。 我將頁面剝離到最低限度,仍然存在問題。 我已經嘗試了多台計算機,但是在Firefox和IE中使用Chrome時仍然無法顯示。

<html>
    <head>
        <title>Test IFrame</title>
    </head>
    <body>
        <iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Fmountainbikingintheus%2F&amp;tabs=timeline&amp;width=350&amp;height=400&amp;small_header=false&amp;adapt_container_width=true&amp;hide_cover=false&amp;show_facepile=true&amp;appId" width="350" height="400" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>
    </body>
</html>

您所有的HTML無效。 至少,您需要將屬性的值放在引號中。 您還應該轉義任何保留的實體,例如& as &amp;

<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Fmountainbikingintheus%2F&amp;tabs=timeline&amp;width=350&amp;height=400&amp;small_header=false&amp;adapt_container_width=true&amp;hide_cover=false&amp;show_facepile=true&amp;appId" width="350" height="400" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>

<iframe height="160" width="300" frameborder="0" allowtransparency="true" scrolling="no" src="https://www.strava.com/athletes/21039441/activity-summary/947ebf6e987358db8c8785041ad46b5a4d4ea7c5"></iframe>

<iframe width="400" height="277" frameborder="0" src="https://www.trailforks.com/widgets/ridelogs/?userid=1306231&amp;w=400px&amp;h=277px&amp;map=0&amp;stats=1"></iframe>

好吧,我是個白痴。 我在3台不同的計算機上嘗試使用Chrome,結果相同。 當iframe是頁面上唯一的項目時,我碰巧瞥了一眼右上角,發現我的廣告攔截器攔截了一些東西。 因此,我關閉了廣告攔截器並重新加載了頁面,效果很好。 因此,將不得不為此尋找一些東西。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM