简体   繁体   English

如何使用window.open创建一个不确定延迟的弹出窗口(对于Social Auth)而没有弹出窗口阻止程序阻止它

[英]How do I create an indeterminately delayed popup (for Social Auth) with window.open without a popup blocker stopping it

The experience I want is: 我想要的经验是:

  1. User clicks "Sign Up" 用户点击“注册”
  2. Some asynchronous server stuff happens (checks & validations. Whatever) 发生了一些异步服务器的事情(检查和验证。无论如何)
  3. Upon completion of the required asynchronous server stuff the Facebook / Twitter / whatever auth dialogs pop up. 完成所需的异步服务器后,将弹出Facebook / Twitter /任何身份验证对话框。

Couple of things that make this hard: 使这很难的几件事:

  1. The social popup widgets must be in a popup. 社交弹出窗口小部件必须在弹出窗口中。 They cannot be inside of an iframe. 他们不能在iframe内。
  2. Popup blockers will block any window.open code that's not in the immediate function of a click handler 弹出窗口阻止程序将阻止任何window.open代码,它不是单击处理程序的直接功能
  3. window.open Code from a standard ajax callback handler will be blocked by popup blockers. window.open来自标准ajax回调处理程序的代码将被弹出窗口阻止程序阻止。
  4. A synchronous ajax request is being deprecated in jQuery 1.8 在jQuery 1.8中不推荐使用同步ajax请求

Any ideas? 有任何想法吗?

This is a common and long-lamented problem . 这是一个常见且长期存在的问题 Though jQuery may be deprecating synchronous AJAX, you could always use a non-jQuery AJAX request. 虽然jQuery可能会弃用同步AJAX,但您总是可以使用非jQuery AJAX请求。 Another possibility would be a refactor where the following takes place: 另一种可能性是重构,其中发生以下情况:

  1. User clicks "Sign Up" 用户点击“注册”
  2. Script calls window.open to a local URI 脚本调用window.open到本地URI
  3. Popup appears and runs the "checks & validations" while loading 弹出窗口出现并在加载时运行“检查和验证”
  4. If there is a validation error, popup sends error to parent and closes itself 如果存在验证错误,弹出窗口会向父级发送错误并自行关闭
  5. If not, local page in popup redirects to FB/Twitter OAuth flow 如果没有,弹出窗口中的本地页面将重定向到FB / Twitter OAuth流程

If that's possible, I suggest that. 如果可能,我建议。 If not, async: false (or writing your own very simple cross-browser XHR wrapper) is still the best way. 如果没有,async:false(或编写自己非常简单的跨浏览器XHR包装器)仍然是最好的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM