Google+登录按钮无法点击

时间:2014-08-02 04:29:50

标签: javascript html google-plus

我关注了Google+ API文档中显示的内容。出于某种原因,我的按钮根本不可点击。什么都没有出现。什么都没发生。我是通过Google Chrome中的网址file:///TestPage.html运行的。

<html>
    <head>
        <title>Test Page</title>
        <script type="text/javascript">
            function onSuccess() {
                //called fine.
            }

            (function() {
                var po = document.createElement('script');
                po.type = 'text/javascript';
                po.async = true;
                po.src = 'https://apis.google.com/js/client:plusone.js?onload=onSuccess';
                var s = document.getElementsByTagName('script')[0];
                s.parentNode.insertBefore(po, s);
            })();

            function onSignInCallback(res) {
                alert('callback'); //doesn't show up.
            }
        </script>
    </head>

    <!-- Not clickable -->
    <button id='signInBtn' class="g-signin"
        data-scope="https://www.googleapis.com/auth/plus.login"
        data-clientid="1085488274737.apps.googleusercontent.com"
        data-callback="onSignInCallback"
        data-theme="dark"
        data-approval-prompt="force"
        data-cookiepolicy="single_host_origin"
        data-requestvisibleactions="http://schemas.google.com/AddActivity"
        data-width="wide">
    </button>
</html>

任何想法为什么没有发生?为什么我的按钮甚至无法点击?

1 个答案:

答案 0 :(得分:0)

正如akonsu所说,请参阅浏览器的控制台

enter image description here

请从本地Web服务器访问该页面,而不是像file:// URL。

这样的简单方法