I came across in a a very strange bug. The "Google Sign In" button do his code when the document is ready. The button do is event when I click on him, But he also do that when the document is ready (and I dont click on him). My code is this:
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<!-- Container with the Sign-In button. -->
<div id="customBtn" class="customGPlusSignIn">
<span class="icon"></span>
<span class="buttonText">Google</span>
</div>
<script type="text/javascript">
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=render';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
/* render button */
function render() {
gapi.signin.render('customBtn', {
'callback': 'onSignInCallback',
'clientid': 'my_clientid.apps.googleusercontent.com',
'cookiepolicy': 'single_host_origin',
'scope': 'https://www.googleapis.com/auth/plus.login'
});
}
function onSignInCallback(resp) {
gapi.client.load('plus', 'v1', apiClientLoaded);
}
function apiClientLoaded() {
gapi.client.plus.people.get({userId: 'me'}).execute(handleEmailResponse);
}
function handleEmailResponse(resp) {
alert(1);
}
</script>
</body>
</html>
In this situation I got the alert(1) when the page is ready. I want to get the alert(1) only when i click on the "google" button.
Thanks to all who read what I wrote :)
EDIT: You can see the bug in the google demo: https://google-developers.appspot.com/+/demos/signin_email_demo?hl=en