chrome ie阻止js弹窗

Open Google

Open Google after 1 second

Open Google after 1 second

Open Google after 1 second

<a href="javascript:void(0);" id="first">Open Google</a><br /><br />
<a href="javascript:void(0);" id="second">Open Google after 1 second</a><br /><br />
<a href="javascript:void(0);" id="last">Open Google after 1 second</a>
<br /><br />
<a href="javascript:void(0);" id="last2">Open Google after 1 second</a>

 

$("#first").click(function(){
   
    window.open("http://www.google.com");
   return false;
});

$("#second").click(function(){
  
    setTimeout(function(){
    window.open("http://www.google.com");
    }, 1000);
    
    return false;
});

$("#last").click(function(){
    var w=window.open();
    setTimeout(function(){
     w.location="http://www.google.com";
    }, 1000);
    
    return false;
});
$("#last2").click(function(){
    var w=window.open();
    setTimeout(function(){
     w.close();
    }, 1000);
    
    return false;
});

貌似只要响应的是用户的操作就可以。

也可以看这个

http://jsfiddle.net/CK6wm/11/

posted @ 2012-08-14 14:28  黄龙  阅读(785)  评论(0编辑  收藏  举报