javascript 如何使弹出窗口始终在顶部
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26101435/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make Popup window always on top
提问by user2854563
I want to open a popup window which should be on top when ever a link from its parent
page is clicked. For example when I click on a link (on a parent page) a popup window open and when I click on another link of parent page the previous popup window become on top of that parent page (and all other open browser's windows)
我想打开一个弹出窗口,当parent
点击其页面上的链接时,该窗口应该位于顶部。例如,当我点击一个链接(在父页面上)一个弹出窗口打开时,当我点击父页面的另一个链接时,上一个弹出窗口成为该父页面(以及所有其他打开的浏览器窗口)的顶部
I have tried the following codes in that popup window HTML but with no luck.
我在弹出窗口 HTML 中尝试了以下代码,但没有成功。
<body onLoad="window.focus();">
and
和
<body onLoad="self.focus();">
and
和
<body onBlur="self.focus();">
Neither of these works. I am using Chrome browser if that helps. Please help!
这些都不起作用。如果有帮助,我正在使用 Chrome 浏览器。请帮忙!
回答by Imran Omer
Try adding .focus()
at the end of your popup window javascript (just before ;
)
尝试.focus()
在弹出窗口的末尾添加javascript(就在 之前;
)