【发布时间】:2014-09-21 23:33:11
【问题描述】:
我根据谷歌文档在页面加载时运行此代码:
(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);
})();
这是我的代码:
gapi.auth.authorize({
'client_id': 'my_client_id',
'immediate': 'false',
'response_type':'token',
'scope': 'https://www.googleapis.com/auth/userinfo.email'
}, function() {
console.log(arguments);
});
如果我在控制台中访问gapi,我会看到该对象。但是,如果我在该代码块处使用断点,gapi 是未定义的。现在,我在这里粘贴的代码是通过内容脚本加载的。如何将gapi 库加载到内容脚本中?
【问题讨论】:
标签: javascript google-chrome google-chrome-extension google-api google-api-client