【问题标题】:FBConnect: Why is it showing on some pages and not others?FBConnect:为什么它显示在某些页面上而不是其他页面上?
【发布时间】:2011-05-12 19:56:09
【问题描述】:

在右上角,显示在这个页面上:

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

但不是这个

http://www.thegreekmerchant.com/

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

【问题讨论】:

    标签: php facebook drupal drupal-6 fbconnect


    【解决方案1】:

    其实问题在于页面使用不同的脚本来加载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 上的第二个脚本。

    【讨论】:

    • @RD 其实不用改http://www.thegreekmerchant.com/product/fokofpolisiekar/band-logo,不过,我强烈推荐。此页面包含我的答案中显示的两个 FB 脚本,并且是多余的(尤其是在看到第一个脚本不起作用时)。说到http://www.thegreekmerchant.com/,你应该把我回答的第一个代码部分改成第二个代码部分。
    【解决方案2】:

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

    <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 或类似工具找出答案。

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

    【讨论】:

      【解决方案3】:

      这些按钮在 Chrome 中都不适用于我,而在 Firefox 上,第一个链接有效,第二个链接无效...

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

      【讨论】:

        【解决方案4】:

        你的错误在:

        (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() 内部永远不会被调用..

        【讨论】:

        • @RD 这是因为工作页面上有两个脚本,看我的回答。
        • @RD 因为在工作页面上,您有“好”行:e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 要查看此行,只需在您的网页上执行“查看源代码”并搜索“all.js”或“connect.facebook”
        猜你喜欢
        • 2011-04-11
        • 2023-01-12
        • 2023-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-07-19
        • 2020-07-25
        • 1970-01-01
        相关资源
        最近更新 更多