javascript新窗口打開連接window.open()被阻攔的解決辦法

場景是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是不行的
相關文章
相關標籤/搜索