检测错误:"popup_blocked_by_browser";用于javascript中的google auth2 [英] detect error: "popup_blocked_by_browser" for google auth2 in javascript
本文介绍了检测错误:"popup_blocked_by_browser";用于javascript中的google auth2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
经过大量谷歌搜索后没有找到解决方案,如何捕获google auth2的弹出窗口阻止程序错误
After lot of googling didn't find solution how to catch error of window popup blocker for google auth2
在控制台错误中出现错误:"popup_blocked_by_browser". 我要做的就是告诉用户应该为身份验证启用弹出窗口.
getting an error in console error: "popup_blocked_by_browser". all I want is to do is tell user that pop up should be enabled for auth.
样本不好,因为它们会打开无用的窗口. 我看到很多人都在寻找这个.
samples using window.open() are not good, since they open useless window. As I see a lot of people searching for this.
有什么建议吗?
推荐答案
最后! signIn()方法使用JS Promise.因此可以使用的代码是:
Finally!! signIn() method uses JS Promise. So code can be used is:
gapi.auth2.getAuthInstance().signIn().then(function(){}, function(error){ if (error) alert('please allow popup for this app')})
希望这会有所帮助!
这篇关于检测错误:"popup_blocked_by_browser";用于javascript中的google auth2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文