本文介绍了jQuery如何防止重新打开新窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面的代码,每当用户按下F2键时,就会打开一个新窗口.
I have the code below to open a new window whenever user presses F2 key.
$(document).bind('keyup', function(e){
if(e.which==113) {
window.open('newPage.htm','_blank','','false');
}
});
现在,我想防止用户在前一个窗口仍处于打开状态的情况下打开新窗口.我如何点它?
Now, I want to prevent user to open a new window while the previous one is still opened. How can I dot it ?
推荐答案
var opened = null;
$(document).bind('keyup', function(e){
if (e.which == 113 && (!opened || !opened.window))
opened = window.open('newPage.htm','_blank','','false');
});
这篇关于jQuery如何防止重新打开新窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!