欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js實(shí)現(xiàn)window.open不被攔截的解決方法匯總

 更新時(shí)間:2014年10月30日 09:25:41   投稿:shichen2014  
這篇文章主要介紹了js實(shí)現(xiàn)window.open不被攔截的解決方法,實(shí)例匯總了常用的不被攔截的解決方法,需要的朋友可以參考下

本文實(shí)例講述了js實(shí)現(xiàn)window.open不被攔截的解決方法。分享給大家供大家參考。具體分析如下:

一、問題:

今天在處理頁面ajax請(qǐng)求過程中,想實(shí)現(xiàn)請(qǐng)求后打開新頁面,就想到通過 js window.open 來實(shí)現(xiàn),但是最終都被瀏覽器攔截了。

二、分析:

在谷歌搜索有沒有解決方法,有些說可以通過新建a標(biāo)簽,模擬點(diǎn)擊來實(shí)現(xiàn),但是測(cè)試發(fā)現(xiàn)都實(shí)現(xiàn)不了,照樣被瀏覽器攔截。
最后找到了一個(gè)折中的辦法,可以實(shí)現(xiàn)新頁面打開,但是沒有a標(biāo)簽的那種直接流量新頁面的效果。

三、實(shí)現(xiàn)代碼:

復(fù)制代碼 代碼如下:
$obj.click(function(){
 var newTab=window.open('about:blank');
 $.ajax({
  success:function(data){
   if(data){
    //window.open('http://www.dbjr.com.cn');
    newTab.location.href="http://www.dbjr.com.cn";
   }
  }
 })
})

其它方法:

復(fù)制代碼 代碼如下:
<script type="text/javascript">
<!--
$(
function()
{
//方法一
window.showModalDialog("http://www.dbjr.com.cn/");
window.showModalDialog("http://www.dbjr.com.cn/");
 

//方法二
var aa=window.open();
setTimeout(function(){
aa.location="http://www.dbjr.com.cn";
}, 100);
 

var b=window.open();
setTimeout(function(){
b.location="http://www.dbjr.com.cn";
}, 200);
 

var c=window.open();
setTimeout(function(){
c.location="http://www.dbjr.com.cn";
}, 300);
 

var d=window.open();
setTimeout(function(){
d.location="http://www.dbjr.com.cn";
}, 400);
 

var ee=window.open();
setTimeout(function(){
ee.location="http://www.dbjr.com.cn";
}, 500);
 

var f=window.open();
setTimeout(function(){
f.location="http://www.dbjr.com.cn";
}, 600);
 

var g=window.open();
setTimeout(function(){
g.location="http://www.dbjr.com.cn";
}, 700);
 

var h=window.open();
setTimeout(function(){
h.location="http://www.dbjr.com.cn";
}, 800);
 

var i=window.open();
setTimeout(function(){
i.location="http://www.dbjr.com.cn";
}, 900);
 

var j=window.open();
setTimeout(function(){
j.location="http://www.dbjr.com.cn";
}, 1000);
 

//方法三
var a = $("<a href='http://www.dbjr.com.cn' target='_blank'>Apple</a>").get(0);
var e = document.createEvent('MouseEvents');
e.initEvent( 'click', true, true );
a.dispatchEvent(e);
 

var a = $("<a href='http://www.dbjr.com.cn' target='_blank'>Apple</a>").get(0);
var e = document.createEvent('MouseEvents');
e.initEvent( 'click', true, true );
a.dispatchEvent(e);
}
 
);
//-->
</script>

希望本文所述對(duì)大家基于javascript的web程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論