FBConnect:为什么它会在某些页面上显示而不在其他页面上显示?

时间:2011-05-12 19:56:09

标签: php facebook drupal drupal-6 fbconnect

在右上角,它显示在此页面上:

http://www.thegreekmerchant.com/product/fokofpolisiekar/band-logo

但不是在这个

http://www.thegreekmerchant.com/

知道为什么吗?我正在使用Drupal 6和FBConnect模块。

4 个答案:

答案 0 :(得分:10)

实际上,问题是页面使用不同的脚本来加载FBConnect模块。

http://www.thegreekmerchant.com/

<div id="fb-root"></div>
  <script type="text/javascript">
    window.fbAsyncInit = function() {
      FB.init({
        appId  : '146943825373452',
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml  : true,
        logging: '0'
      });

      jQuery(document).trigger('fb:init');
    };

    (function() {
      var e = document.createElement('script');
      e.src = document.location.protocol + '//connect.facebook.net//all.js';
      e.async = true;
      document.getElementById('fb-root').appendChild(e);
    }());
  </script>

http://www.thegreekmerchant.com/product/fokofpolisiekar/band-logo上有两个脚本,前一个和下一个:

<div id="fb-root"></div><script type="text/javascript">
 window.fbAsyncInit = function() {
   FB.init({
     appId: "146943825373452",
     status: true, 
     cookie: true,
     xfbml: true
   });

   FB.Event.subscribe("edge.create", function(href, widget) {
      _gaq.push(["_trackEvent", "Facebook like", "Drupal", href]);
   });


 };
 (function() {
   var e = document.createElement('script'); 
   e.async = true;
   e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
   document.getElementById('fb-root').appendChild(e);
 }());
</script>

我已将第一个脚本替换为第二个脚本,http://www.thegreekmerchant.com/现在可以正常工作(当然不是尖锐版本,但在我的沙盒服务器上)。您只需要http://www.thegreekmerchant.com/product/fokofpolisiekar/band-logo上的第二个脚本。

答案 1 :(得分:7)

在工作页面上,您有这个标记:

<div id="fbconnect_button-wrapper" class="form-item">
  <fb:login-button v="2" background="dark" onlogin="facebook_onlogin_ready();" size="small">
    <a class="fb_button fb_button_small">
      <span class="fb_button_text">Facebook Connect</span>
    </a>
  </fb:login-button>
  <div class="description">Sign in using Facebook</div>
</div>

在非工作方面你有这个:

<div id="fbconnect_button-wrapper" class="form-item">
  <fb:login-button v="2" background="dark" onlogin="facebook_onlogin_ready();" size="small">
    Facebook Connect
  </fb:login-button>
  <div class="description">Sign in using Facebook</div>
</div>

我认为,创建标记的JavaScript无法正常运行。也许在执行FB按钮脚本之前还有另一个JavaScript错误。使用Firebug或类似的工具来找出它。

如果没有更多信息,很难提供帮助。

答案 2 :(得分:2)

这些按钮在chrome中都不适合我,而在firefox上第一个链接正在工作而第二个链接没有...

问题是firefox上的主页将cpu加载发送到100%,我看到你家里有大量的javascripts。我会尝试禁用其他javascripts并最终对页面源进行检查以查看是否有任何损坏的内容。

答案 3 :(得分:2)

您的错误是:

(function() {
      var e = document.createElement('script');
      e.src = document.location.protocol + '//connect.facebook.net//all.js';
      e.async = true;
      document.getElementById('fb-root').appendChild(e);
    }());

该行:

e.src = document.location.protocol + '//connect.facebook.net//all.js';

应该是

之类的东西
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';

如果您观看浏览器下载的all.js文件,您将看到错误。

因此没有加载FB脚本,因此永远不会调用window.fbAsyncInit = function()的内部..

相关问题