ajax中打开新页面使用window.open方法被拦截的解决方法
$('.testA').unbind('click').bind('click',function(){
var result="";
$.ajax({
url:'http://localhost/demo/windowopen/test.php',
'type':'POST',
async:false,
dataType:'json',
success: function(data){
if(data && data.success) {
result=data.result;//假如这就是返回的‘http://www.baidu.com';
window.open('http://www.baidu.com');
}
}
});
if(result.length>5){//判断url是否有值
window.open(retsult);//这样就不会open就不会被屏蔽了,我测试了几个浏览器都可以,欢迎测试提出意见
}
});
浙公网安备 33010602011771号