0

我正在使用 google oauth2 javascript api 对我的应用程序的用户进行身份验证。这在 Firefox 和 chrome 中运行良好,但在 IE 中不行。我在 IE 8、9 和 10 中尝试过,但没有成功。我在网上搜索了很多,但没有得到任何解决方案。我已经完成了 stackoverflow 问题1428548014830177。如果这是谷歌中现有的错误,那么是否有任何替代方法?我正在尝试下面的代码。我没有足够的 stackoverflow 点来评论任何问题,所以提出一个新问题。请帮忙。

这是我的代码

 <html>
    <head>
    <script type="text/javascript">       
        window.setTimeout(function() {        
            var po = document.createElement('script'); 
            po.type = 'text/javascript'; po.async = true;        
            po.src = 'https://apis.google.com/js/client:plusone.js';        
            var s = document.getElementsByTagName('script')[0]; 
            s.parentNode.insertBefore(po, s);      
        },1000)(); 

        function signinCallback(authResult) {   
            if (authResult['access_token']) { 
                 document.getElementById('signinButton').setAttribute('style', 'display: none');
            } 
            else if (authResult['error']) {   
                 console.log('Sign-in state: ' + authResult['error']);   
            } 
        }

    </script>
    </head>
    <body>
    <span id="signinButton">
        <span 
        class="g-signin" 
        data-callback="signinCallback" 
        data-clientid="my clinetid" 
        data-cookiepolicy="single_host_origin" 
        data-requestvisibleactions="http://schemas.google.com/AddActivity"     
        data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile">   
        </span> 
    </span> 
    </body>
    </html>
4

1 回答 1

1

尝试这个。

<html>
    <head>
    <script type="text/javascript">       
function signinCallback(authResult) {   
            if (authResult['access_token']) { 
                 document.getElementById('signinButton').setAttribute('style', 'display: none');

            } 
            else if (authResult['error']) {   
                 console.log('Sign-in state: ' + authResult['error']);   
            } 
        }

    </script>
    </head>
    <body>
    <span id="signinButton">
        <span 
        class="g-signin" 
        data-callback="signinCallback" 
        data-clientid="my clinetid" 
        data-cookiepolicy="single_host_origin" 
        data-requestvisibleactions="http://schemas.google.com/AddActivity"     
        data-scope="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile">   
        </span> 
    </span>
<script type="text/javascript">
  var po = document.createElement('script'); 
  po.type = 'text/javascript'; po.async = true;        
  po.src = 'https://apis.google.com/js/client:plusone.js';        
  var s = document.getElementsByTagName('script')[0]; 
  s.parentNode.insertBefore(po, s);      
</script>
    </body>
    </html>
于 2014-02-11T09:20:10.397 回答