我正在尝试使用 Github API 的 网络身份验证流程从 AngularJS 应用程序中.当我的注册表单提交时,我想打开一个新窗口将它们发送到身份验证页面.通常我只会在用户事件中使用 window.open
以确保它不会被弹出窗口阻止程序捕获.
I am trying to use the Github API's web auth flow from within an AngularJS app. When my signup form submits, I want to open a new window to send them to the the auth page. Normally I would just use window.open
inside a user event to ensure it wouldn't get caught by a popup blocker.
在我的 Angular 应用程序中,我在 Angular 服务中封装了一些 Github api,打开窗口的代码就在其中.正因为如此,它被阻塞了.我还尝试将它放在控制器中的一个函数中,该函数由表单通过 ng-submit
调用.
In my angular app, I am wrapping a bit of the Github api in and Angular service, and the code to open the window goes in there. Because of that it gets blocked. I also tried putting it in a function in the controller that gets called by a form via ng-submit
.
所以问题是,有没有一种优雅的方法可以从我的服务或控制器内部的某个地方打开表单提交的新页面,还是我需要找到另一种方法来做到这一点?
So the question is, is there an elegant way to open a new page on a form submit from somewhere inside my service or controller, or will I need to find another way to do it?
您无法摆脱脚本自动化 window.open 的弹出窗口阻止程序.只有真实用户的号召性用语事件才会打开一个新窗口,而不会被弹出窗口阻止程序阻止.想象一个网站的情况,浏览器中没有弹出窗口阻止程序,而 javascript 循环打开 100 个弹出窗口.你想要吗?它曾经像病毒一样在我们过去的美好时光中存在,但现代浏览器非常聪明,并且可以优雅地处理这种烦恼.
You can't get rid of the popup blocker for scripted automated window.open. Only real user's call to action events will open a new window without being blocked by popup blocker. Imagine a situation in a site where there's no popup blocker in browser and javascript opens 100 popups in a loop. Would you like it ? It used to be there in our old good times like a virus but modern browsers are much smart and this annoyance is handled gracefully.
这篇关于Angularjs $window.open 弹出窗口被阻止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!