jQuery.ajax({
      "type":"post",
      "url":"http://www.baidu.com", 
      "success":function(rel){
           if(rel.isSuccess){ 
                window.open(rel.url,"_blank");
    }
      }
});

这个url请求成功后window.open(rel.url,"_blank");会被浏览器拦截,无法打开新窗口,如果把window.open()放在ajax外面,问题就迎刃而解,代码如下:

var result="";
 
jQuery.ajax({
      "type":"post",
      "url":"http://www.baidu.com", 
      "success":function(rel){
           if(rel.isSuccess){ 
  result=rel.url;
                //window.open(rel.url,"_blank");
    }
      }
});
 
if(result.length>0){
      window.open(result,"_blank");
}

 

相关文章:

  • 2021-05-21
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2021-12-06
  • 2021-10-16
  • 2022-02-11
  • 2022-12-23
猜你喜欢
  • 2021-07-13
  • 2021-07-03
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案