场景是ajax提交,比较后端效验数据,须要用户登陆,提示后并须要新窗口打开登陆的连接,使用window.open(url);每每会被浏览器认为是广告而被拦截。
data.url是ajax返回的连接地址
1 //window.open(data.url); #新窗口打开连接,浏览器会当成广告阻截,因此改换如下方式 : 2 3 var strA=document.createElement("a"); 4 strA.target="_blank"; 5 strA.id="alogin"; 6 strA.href=data.url; 7 strA.text="测试"; 8 strA.style.display="none"; 9 document.body.appendChild(strA); 10 document.getElementById("alogin").click(); 11 12 //$("#asetpaypwd").click(); 测试,这里使用jquery是不行的