[英]stop child page reloading on additional clicks
单击按钮时,将打开一个子窗口。 然后,如果再次单击它将重新加载该页面。 我试图避免这种情况发生,即使重新加载父页面也是如此。 只要子页面“ test”处于打开状态,我都希望click事件中的条件对子窗口不执行任何操作并发出警告。 这可能吗? 谢谢
$('#send').click(function(){
if(*child page already open*){
alert('already open');
}else{
window.open("test.html","Ratting","width=550,height=170,0,status=0,");
}
});
您需要测试子窗口是否存在 并 仍处于打开状态 :
var childWindow;
$('#send').click(function(){
if (childWindow && !childWindow.closed) {
alert('already open');
} else {
childWindow = window.open("test.html","Ratting","width=550,height=170,0,status=0,");
}
});
var childPage = null;
$('#send').click(function(){
if(childPage && !childPage.closed){
alert('already open');
} else{
childPage = window.open("test.html","Ratting","width=550,height=170,0,status=0,");
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.