使用 window.open() 方法打开新窗口会被浏览器拦截,可以绕开这个拦截机制,利用异步调用并使用变量后赋值url的方法,代码如下:
$.ajax({
url:'your url',
type: 'get',
success: (data, status, xhr) => {
// 新建变量,实例化window.open,然后再赋值url
const _window = window.open()
_window.location.href = 'your url'
}
})