标签:
转自:http://www.cnblogs.com/linjiqin/p/3148205.html
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"); }
标签:
原文地址:http://www.cnblogs.com/lvchenfeng/p/5295879.html