問題描述
所以,問題在于彈出窗口會阻止窗口打開,即使它是由用戶操作完成的,例如單擊..
So, the problem is that popup blocking the window open even if it is done by a user action, click for example..
gapi.auth.authorize({
client_id: this.client_id,
scope: this.scopes,
access_type: 'online',
immediate: immediate
}, function(authResult) {
console.log(authResult)
});
如果我只是在用戶點擊此處打開窗口:
If i simply open the window on user click as here:
$('.some').click(funciton(){
window.open(someurl)
})
它工作正常,但如果我這樣做了,它會拋出 gdrive api(gapi.auth.authorize),無論如何都會阻塞.
it works fine, but if i did it throw the gdrive api(gapi.auth.authorize), this blocking anyway.
必須,我不能強迫用戶關閉彈出窗口阻止.我希望任何人現在如何解決它:),謝謝
A must, I can not force users to off popap blocking. I hope that anybody now how solved it :), thanks
推薦答案
試試這個:
在對 client.js 的調用中包含一個 onload 事件
Include an onload event in your call to client.js
<script type="text/javascript" src="https://apis.google.com/js/client.js?onload=handleClientLoad"></script>
從 onload 函數調用 gapi.auth.init:
Call gapi.auth.init from the onload function:
function handleClientLoad() { window.setTimeout(gapi.auth.init,1);}
在您的授權配置中設置立即:false.
In your authorize configuration set immediate: false.
檢查頁面流中 1. 是否低于 2..
Check that 1. is below 2. in the flow of the page.
這篇關于在 chrome 中阻止 gdrive 授權的彈出窗口的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!