Javascript Jquery单击之间的时间
有人能告诉我这里的问题出在哪里吗?我想在我单击“自动”开始打开新窗口时延迟3秒Javascript Jquery单击之间的时间,javascript,jquery,each,settimeout,Javascript,Jquery,Each,Settimeout,有人能告诉我这里的问题出在哪里吗?我想在我单击“自动”开始打开新窗口时延迟3秒 $('#automatic').click(function(){ $('.autosend').each(function() { //window.open( $(this).attr('href') ); var openwindow = window.open( $(this).attr('href') ); setTimeout(openwindow,
$('#automatic').click(function(){
$('.autosend').each(function() {
//window.open( $(this).attr('href') );
var openwindow = window.open( $(this).attr('href') );
setTimeout(openwindow,3000);
});
});
如果您需要以3秒的延迟打开新窗口,则该行错误:
setTimeout(openwindow,3000);
$(函数(){
$(“#自动”)。单击(函数(){
$('.autosend')。每个(函数(索引,元素){
$('#txt').text($('#txt').text()+'\n'+(索引*3000));
setTimeout(函数(){
var openwindow=window.open($(this.attr('href'));
$('#txt').text($('#txt').text()+'\n'+'窗口打开:'+$(this.attr('href'));
}.bind(本),索引*3000);
});
});
});代码>
自动的
我猜问题在于现代浏览器中内置的“弹出窗口拦截器”,以确保这样令人讨厌的废话不可能发生,