【问题标题】:Getting a black frame inside the iframe while clicking a tab item in Facebook iFrame application在 Facebook iFrame 应用程序中单击选项卡项时在 iframe 中出现黑框
【发布时间】:2010-07-09 06:45:50
【问题描述】:

我正在为现有网站开发 Facebook iFrame 应用程序。我使用<iframe> 代码加载网页。我还有一个选项卡部分,包括选项卡项 Home、InviteFriends 等。但是选项卡和加载的网页之间有很多空白空间。

这是我的 index.php 文件

 <?php
  require_once 'appinclude.php';
  $user_id = $facebook->require_login();
 ?>

 <html xmlns="http://www.w3.org/1999/xhtml" 
 xmlns:fb="http://www.facebook.com/2008/fbml">  

 <head></head>   

 <body>   
 <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" 
         type="text/javascript"></script>

 <div id="FB_HiddenIFrameContainer" style="display:none; position:absolute; left:-100px; top:-100px; width:0px; height: 0px;"></div>

 <fb:serverfbml style="height:200px; width:760px;"> 
 <script type="text/fbml"> 
  <fb:fbml> 
  <fb:tabs>
       <fb:tab-item href='http://my_site_ip/my_app_folder/' title='Home'       selected='true' target="_TOP"/>
     <fb:tab-item href='http://my_site_ip/my_app_folder/fav.php' title='My Favorites' target="_TOP"/>
     <fb:tab-item href="http://my_site_ip/my_app_folder/invite.php" title="Invite Friends" target="_TOP"/>    
   </fb:tabs>
   </fb:fbml>
 </script>
 </fb:serverfbml>

<?php echo '<iframe name="qantas" height="640px" width="740px" frameborder="0"    resizeable="true" scrolling="no" style="border:none" src="my_url" target="_TOP"></iframe>';?>

 <script type="text/javascript"> 

    FB.init("my_api_key", "../channel/xd_receiver.htm");

    FB_RequireFeatures(["CanvasUtil"], function(){
        FB.XdComm.Server.init("../channel/xd_receiver.htm");
        FB.CanvasClient.startTimerToSizeToContent();
});

  </script>    
 </body>  
</html>  

当我点击邀请朋友选项卡时,我在加载的网页上方的屏幕上看到一个黑框,而不是空白区域。如果我单击黑色区域,它会导航到邀请页面。如何去掉这个黑框,直接导航到邀请页面?

这是我的邀请.php 文件:

 <?php
  require_once 'appinclude.php';
  $user_id = $facebook->require_login();
 ?>

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:fb="http://www.facebook.com/2008/fbml">  

<head></head>   

<body>   

<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"
 type="text/javascript">
</script>

<fb:serverfbml style="width: 776px;"> 
<script type="text/fbml"> 
  <fb:fbml> 
  <fb:tabs>
     <fb:tab-item href='http://apps.facebook.com/my_canvas_url/' title='Home'       selected='true' target="_TOP"/>
<fb:tab-item href='http://apps.facebook.com/my_canvas_url/fav.php' title='My Favorites' target="_TOP"/>
<fb:tab-item href="http://apps.facebook.com/my_canvas_url/invite.php" title="Invite Friends" target="_TOP"/>     
   </fb:tabs>

 <fb:request-form action="http://my_localhost_ip/FacebookApp/" 
        method="POST" 
        invite="true" 
        type="myWEb"
        target="_parent" 
        content="<fb:name uid='$user_id' useyou='false'></fb:name> is a member of myWeb.com and would like to share that experience with you.To register, simply click on the 'Register' button below.<fb:req-choice url='http://apps.facebook.com/my_canvas_url/index.php' label='Register'/>"> 

     <fb:multi-friend-selector showborder="false" actiontext="Invite your Facebook Friends to use myWeb" /> 

  </fb:request-form> 
  </fb:fbml> 
 </script>
 </fb:serverfbml> 

 <script type="text/javascript"> 
        FB.init("my_api_key", "../channel/xd_receiver.htm");
 </script>   
</body>  
</html>  

【问题讨论】:

  • 现在我已将选项卡项中的 href 更改为指向我的站点。现在我得到的不是黑色层,而是邀请页面,但在那个小盒子里。 Target="_top" 和 target="_parent" 不做任何更改。

标签: facebook tabitem facebook-iframe


【解决方案1】:

在 iframe 应用程序中,我通过 javascript 重定向客户端解决了黑色(或灰色)层问题,使用

window.top.location.replace("http://apps.facebook.com/canvas_url/page_with_dark_layer");

【讨论】:

  • 现在我得到一个找不到页面的错误。 :-( 而不是那个黑色层
  • 网址末尾没有“层”参数,我只是在答案中修复了它。您只需将邀请朋友选项卡的 URL 提供给 javascript 的 location.replace() 函数即可。
  • 好吧,我没有注意到任何层参数,所以我只给出了邀请朋友选项卡的 url(这是你现在建议的,rt?)。然而我仍然得到那一层。当我使用onclick函数时,我应该保留href=''还是href='#'
【解决方案2】:

似乎目标属性不适用于选项卡项。所以我按照 Facebook 开发者论坛成员的建议使用了 html 和 css 的组合。这是链接http://forum.developers.facebook.com/viewtopic.php?pid=121903,我从中获取代码并相应地更改了我的应用程序。该人已提供 css 代码以使链接看起来像 Facebook 选项卡。因此,任何在使用 Tab 项时遇到此灰色框问题的人都可以使用该代码。

【讨论】:

    猜你喜欢
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-06
    • 2011-05-31
    • 1970-01-01
    相关资源
    最近更新 更多