0

I am thinking about opening the help page of my application in a popup1. My problem is that I don't want to open multiple popups if the user clicks the help button more then once.

Is it possible, in a cross-browser way, to reuse an old popup window instead of opening a new one?. I'm hoping I can bring it back to the foreground2 or something like that.

In the worst case I think I can go back to a div-based Javascript dialog but I'd rather avoid that if possible.


1 Most normal desktop apps use popups for the help dialogs so I don't think there is anything wrong with this choice.

Also, I think in my case a normal link to a help page would be suboptimal from a practical perspective (I don't want people navigating around too much in my single-page app) and from a technical one (the help contents are created via Javascript and using popups + document.write is more flexible for me)

2 Some comparisons with Windows desktop apps: Windows Explorer and IE refocus the old help window if you try to open it again. Office apps have the help window always on top. Firefow and Chrome just open a new browser tab (and open multiple ones if you try again)

hugomg
  • 68,213
  • 24
  • 160
  • 246
  • I am aware of [this question](http://stackoverflow.com/questions/1464840/is-there-a-cross-browser-method-to-bring-a-popup-window-into-the-foreground) but all it said is "don't do it" so my curiosity is not satisfied... – hugomg Nov 21 '11 at 22:05

2 Answers2

3

I usually just use focus()

 function help_open(id) {
 newwindow = window.open('help.php?id=' + id, 'popup_return',     'menubar=no,history=no,resizable=yes,scrollbars=yes,toolbar=no,width=800,height=600');
if (window.focus) {newwindow.focus()}
   }
AR.
  • 1,935
  • 1
  • 11
  • 14
  • Hmm, turns out I was misled by just Chrome [not implementing](http://stackoverflow.com/questions/2758608/window-focus-not-working-in-google-chrome) this method... – hugomg Nov 21 '11 at 22:13
  • Turns out I needed to put actual data into the window to make this work. Browsers seem to ignore window.focus() calls on about:blank – hugomg Nov 21 '11 at 22:33
0
<a href="something" target="yourname">

while yourname same the same window will be focused

Tigra
  • 2,611
  • 20
  • 22