的window.open()由浏览器阻止时,从承诺称为 [英] window.open() is blocked by browser when is called from promise

查看:114
本文介绍了的window.open()由浏览器阻止时,从承诺称为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code是这样的:

I have code like this:

window.open('https://api.instagram.com/oauth/authorize/',
'_blank',
'width=700,height=500,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=1,left=0,top=0,modal=yes');

这正常工作时是从code任何地方叫,但是当我的承诺(见下文)使用它,它总是阻止浏览器。有什么建议?

This works fine when is called from any place of code, but when I use it in promise (see below), it is always blocked by browser. Any suggestions?

action().success(function (r) {
  // window.open(...);
}

承诺从棱角分明。

Promises are from angular.

推荐答案

在响应您是否获得了HTTP响应从Ajax请求回来的承诺火灾。这不是一个用户触发的事件,因此弹出窗口被阻止。使用用户给出创建一个新的你代替窗口

The promise fires in response to you getting the HTTP response back from the Ajax request. That isn't a user triggered event, so popups are blocked. Use the window the user gives you instead of creating a new one.

这篇关于的window.open()由浏览器阻止时,从承诺称为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆