3

这是我的代码

<html>
    <head>
        <head>
            <title></title>

           <script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>
           <script type="text/javascript">



                    function go()
                    {

                        FB.login(function(response) {
                                 if (response.authResponse) {
                                 console.log('Welcome!  Fetching your information.... ');
                                 FB.api('/me', function(response) {
                                        console.log('Good to see you, ' + response.name + '.');
                                        });
                                 } else {
                                 console.log('User cancelled login or did not fully authorize.');
                                 }
                                 });                        

                    }





                </script>

                <body>
                    <div id="fb-root">

                    </div>

                    <script>
                        window.fbAsyncInit = function() {
                            FB.init({
                                    appId      : '', // App ID
                                    channelUrl : '', // Channel File
                                    status     : true, // check login status
                                    cookie     : true, // enable cookies to allow the server to access the session
                                    xfbml      : true,  // parse XFBML
                                    oauth      : true  //oauth v2.0 
                                    });

                        };


                        // 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));

                        </script>

                    <input onclick="go();" type='submit' id='login-button' value='Login' name='login' >

                </body>
</html>

基本上,您单击该按钮,它应该会显示一个登录弹出窗口。当我在普通浏览器中尝试时它可以工作,但是当我在 iPhone 模拟器中尝试时没有任何反应。iv 还将 iPhone 浏览器设置为允许弹出窗口。我究竟做错了什么?

4

1 回答 1

1

我使用名为 Childbrowser 的 phonegap 插件让它工作了 :)

于 2012-04-20T10:03:42.533 回答