0

我在 asp.net mvc3 中查看了产品列表,当用户单击产品时,用户会转到带有产品详细信息的另一个视图,问题是当页面完成加载时,facebook like 按钮没有显示。但是,如果我刷新页面,它就会显示,其中 google plus +1 按钮工作正常。帮助请。

<!DOCTYPE html>
<html>
    <head>
         <meta charset="utf-8" />
         <meta name="viewport" content="initial-scale=1.0, width=device-width, height=device-height,user-scalable=no" />
         <title>xxxxxxxx</title>
         <link href="/Content/Site.css" rel="stylesheet" type="text/css" />
         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"> </script>
         <link href="/Content/JqueryContent/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
         <script src="/Content/JqueryContent/jquery.ui.core.js.js" type="text/javascript"></script> 
         <script src="/Content/JqueryContent/jquery.ui.widget.js.js" type="text/javascript"></script>
         <script src="/Content/JqueryContent/jquery.ui.position.js" type="text/javascript"></script>
         <script src="/Content/JqueryContent/jquery.ui.autocomplete.js" type="text/javascript"></script>
         <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
         <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js" type="text/javascript"> </script>
    </head>
    <body>
    <div id="fb-root"></div>
    <script type="text/javascript">
            window.fbAsyncInit = function() {
              FB.init({
                appId      : 'xxxxxxxxxxxx',
                status     : true, 
                cookie     : true,
                xfbml      : true,
                oauth      : true,
              });
              FB.Event.subscribe('auth.statusChange', handleStatusChange);
            };

            (function(d){
               var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
               js = d.createElement('script'); js.id = id; js.async = true;
               js.src = "//connect.facebook.net/en_US/all.js";
               d.getElementsByTagName('head')[0].appendChild(js);
             }(document));
    </script>
    <header data-role="header" data-theme="a"><h3>xxxxx</h3></header>
    <div data-role="content">
    <div class="fb-like" data-send="true" data-width="450" data-show-faces="true"></div>
    <style>.fb_edge_comment_widget {display: none !important; }</style> 
    <div class="g-plusone" data-size="medium"></div>
    <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>    
    </div>
    <footer data-role="footer" data-theme="a" style="font-family:Trebuchet MS;"><h5></h5></footer>
</body>
</html>
4

1 回答 1

0

您可能想要更新您的 FB sdk 片段。我刚刚检查了 Facebook Javascript SDK 页面,它是这样做的:

// Load the SDK Asynchronously
  (function(d){
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
     if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "//connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));

注意插入 js 的新方法,insertBefore(). 也许这会有所帮助。

干杯!

于 2012-06-08T19:43:14.497 回答