发布于 2015-09-17 17:21:34
您的代码有点奇怪,因此很难正确地进行调整,但这是它的要点:
showNewWindow: function(menu) {
var me = this,
newWindowId = sports.util.Utils.randomString(12);
//
// Make a synchronous request so that the new window will
// not load as a popup.
//
debugger;
var popup = sports.util.Utils.openNewWindow('', 'menu', {}, null, null, newWindowId);
Ext.Ajax.request({
async: false,
url: sports.util.Utils.getContextPath() + '/tabClicks.do',
params: {
oldWindowId: sports.util.Utils.getWindowName(),
newWindowId: newWindowId
},
success: function() {
popup.location.href = "/desktop/main";
},
scope: me
});
},发布于 2015-09-17 16:56:23
弹出阻止程序试图判断何时打开窗口是为了直接响应用户操作,还是由应用程序自发地打开。他们这样做的方式可能是检查名为window.open()的函数是否是针对用户触发的事件运行的,比如鼠标单击。
执行同步AJAX请求时,当响应到达并成功函数调用window.open时,鼠标单击触发的函数仍在运行。因此,它被认为是用户请求的窗口,而不是弹出窗口。
使用异步AJAX时,当成功函数运行时,单击处理程序将不再运行。浏览器认为对window.open的异步调用是自发的,因此它会阻止它。
我不认为有任何解决办法,因为你能做的任何事情也可以被其他人用来绕过弹出阻断器,它们将是无用的。
发布于 2017-02-03 07:55:30
function openNewWin(name) {
$.ajax({
async: false,
type: 'POST',
url: 'your url',
success: function () {
window.open(name);
},
async: false
});
}https://stackoverflow.com/questions/32635231
复制相似问题