1 打开新窗口,window.open(),这本身并不会被浏览器阻止,但是放在ajax方法中,弹出新窗口就被阻止了,如下:
function mfopen(id, name) { jQuery.ajax({ type: "GET", dataType: "text", url: "UserLogin.aspx?method=init", success: function (msg) { var Json = eval("(" + msg + ")"); if (Json.result == "100") { if ( Json.isagtuser != "0") { jErpPopup("没有资格", 'no.aspx', 415, 90, function () { }); } else { var cid = id; var cname = name; var url = 'chuli.aspx?id=' + cid + '&name=' + escape(cname) + '&num=Math.Random()' + ''; window.open(url); } } else { jErpPopup("您还没有登录,请先登录", 'Login.aspx?fun=pingjiaagent2', 410, 180, function () { }); } } }); }
2,ajax默认异步,修改为同步执行,可以解决弹出新窗口被浏览器阻止的问题,如下:
function mfopen(id, name) {
jQuery.ajax({
type: "GET",
async:false,
dataType: "text",
url: "UserLogin.aspx?method=init",
success: function (msg) {
var Json = eval("(" + msg + ")");
if (Json.result == "100") {
if ( Json.isagtuser != "0") {
jErpPopup("没有资格", 'no.aspx', 415, 90, function () { });
}
else {
var cid = id;
var cname = name;
var url = 'chuli.aspx?id=' + cid + '&name=' + escape(cname) + '&num=Math.Random()' + '';
window.open(url);
}
}
else {
jErpPopup("您还没有登录,请先登录", 'Login.aspx?fun=pingjiaagent2', 410, 180, function () { });
}
}
});
}