我在使用Google+登錄時遇到了一個奇怪的問題。我使用的代碼與他們在開發者網站上發佈的內容非常接近。問題Google+在Chrome上登錄
我的代碼
<script type="text/javascript">
var auth2;
var initClient = function() {
gapi.load('auth2', function() {
auth2 = gapi.auth2.init({
client_id: 'MYCLIENTIDHERE.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
scope: 'profile'
});
jQuery('#signin-button').unbind();
auth2.attachClickHandler('signin-button', {}, onSuccess, onFailure);
});
};
var onSuccess = function(user) {
console.log('Signed in as ' + user.getBasicProfile().getName());
do_all_my_other_stuff_not_important_for_here();
};
var onFailure = function(error) {
console.log(error);
};
</script>
行爲
當點擊Chrome中的#singin-button
,大部分時間什麼都不似乎發生。如果在其他瀏覽器中,如Firefox,則按預期工作。
我很確定我的代碼中沒有別的東西搞砸了,因爲當我在本地機器上運行相同的源代碼時,它也按預期工作(不管瀏覽器如何)。
問題
我真的很茫然到哪裏,甚至開始進一步診斷此問題。你會怎麼做?對於在哪裏尋找可能的解決方案的想法是值得歡迎的。