什么情况下会弹窗被拦截
obj.onclick = function(){
window.open(url) // 会被拦截
}
obj.onclick = function () {
ajax({
url: ‘/xxxxxx/’,
success: function (url) {
window.open(url); // 会被拦截
}
})
}
});
解决
obj.onclick = function () {
var newWindow = window.open(); // 先在回调函数之前打开新窗口,后再加载 url
ajax({
url: ‘/xxxxxx/’,
success: function (url) {
newWindow.location.href = url;
}
})
}