弹出到前面 [英] bring popup to front
问题描述
在我的应用程序中,我有一个弹出窗口,当我选择一些选项时会打开信息。
第一次是OK,弹出窗口,显示所有内容。但是,当他失去焦点时,当用户转到其他窗口时,如果用户再次点击相同的选项,我希望该弹出窗口再次显示在所有内容的前面。我尝试类似:
< body onLoad = this.focus()>
window.focus();
document.focus();
this.focus();
但是dos不适合我。
我缺少什么?
您应该保留对您打开的弹出窗口的引用并调用焦点方法。
var win = window.open(url,name,args);
win.focus();
当您打开一个弹出框时,如果您提供了一个名称,并且下次打开一个具有相同名称的弹出窗口如果未关闭,它将使用相同的弹出窗口。你只需要关注它。
你可以使用这个简单的函数来处理弹出窗口
function windowOpener(url,name,args){
if(typeof(popupWin)!=object|| popupWin.closed){
popupWin = window.open (网址,名称,参数);
}
其他{
popupWin.location.href = url;
}
popupWin.focus();
}
in my application, i have a popup with informations that open when i choose some options.
first time its OK, popup hightlight in front of everything.
But, when he lose focus, when the user go's to other window, if user click again in the same option, i want that popup show's up again, in front of everything.
i try something like:
<body onLoad="this.focus()">
window.focus();
document.focus();
this.focus();
but dos not work for me.
what i'm missing ?
You should maintain a reference to the popup window you open and call focus method on it.
var win = window.open(url, name, args);
win.focus();
While opening a popup if you give a name and next time when you open a popup with the same name it will use the same popup if it is not closed. You just have to focus it.
You can use this simple function to handle popups
function windowOpener(url, name, args) {
if(typeof(popupWin) != "object" || popupWin.closed) {
popupWin = window.open(url, name, args);
}
else{
popupWin.location.href = url;
}
popupWin.focus();
}
这篇关于弹出到前面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!