虽然以下代码在使用Chrome时可以正常工作(显示一个弹出窗口,请求用户允许访问地图和位置数据),但在IE 9中调用handleAuthClick方法时,弹出窗口是空的。我已经尝试添加setTimeouts,但没有效果。我确保了弹出窗口被允许,并检查了弹出窗口页面的URL,在Chrome和IE中都是相同的。有人遇到过这个问题吗?或者有人能提供一个解决方法吗?
var clientId = '############.apps.googleusercontent.com';
var apiKey = '#A#A#A#A##';
var scopes = 'https://www.googleapis.com/auth/plus.me';
function handleClientLoad() {
gapi.client.setApiKey(apiKey);
window.setTimeout(checkAuth, 1);
}
function checkAuth() {
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: true }, handleAuthResult);
}
function handleAuthResult(authResult) {
if (authResult && !authResult.error) {
makeApiCall();
} else {
}
}
function handleAuthClick(event) {
try {
window.setTimeout(function () {
gapi.auth.authorize({ client_id: clientId, scope: scopes, immediate: false }, handleAuthResult);
}, 10);
} catch (e) { alert(e.message); }
}
function makeApiCall() {
gapi.client.load('plus', 'v1', function () {
var request = gapi.client.plus.people.get({
'userId': 'me'
});
request.execute(function (resp) {
$(".google-signin").find("img").attr('src', resp.image.url).css('height', '32').css('width', '32');
$("#login-msg").text('Welcome: ' + resp.displayName);
$("img.vote").css('visibility', 'visible');
});
});
}