• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

Javascript reopening popup

Hi everybody,

In one of my PHP page I open a popup (window.open(...)) whern the user cliks on a button.
I'd like to close this popup window when the focus is not on this window anymore, i.e when the user has clicked on another window, and thus the popup window is not anymore on top.
So that I could re-open the pop up as many times as the user clicks my button, avoiding him to look for the popup window in the taskbar.
Hope I've been clear...
Thanks for advance,
Vincent
0
vinceTrace
Asked:
vinceTrace
  • 3
  • 2
1 Solution
 
Cyber-DrugsCommented:
Why not make use of a floating <div> element, rather than a popup window. This way you can just set the div to hide (rather than physically close) and unhide as often as you like.

Alternatively, you could grab the innerHTML() of the popup window in question, store the content in a variable, and re-open the window when needed, and populate it with the content which is stored in a variable.


Hope this helped.
0
 
vinceTraceAuthor Commented:
Thanks for your help.
To be consistant with my other pages I would prefer the popup solution, even if zhis is probably a less elegant solution...
Could you tell me more about the second solution?
0
 
Cyber-DrugsCommented:
I'm not able to test anything at the moment, but try this....

When creating your popup initially, do something like this:


var oPopup = window.createPopup();

That way your popup has a name reference, after that, do this:


var contentPopup = Popup.document.body.innerHTML;


contentPopup now contains the source code for the popup, when you recreate the pop, do something like:


Popup.document.body.innerHTML = contentPopup;



That's just the pseudo code, try it out, and if you have problems I'll take a look when I get home this evening for you.
0
 
vinceTraceAuthor Commented:
Can I set images within the popup?
When I said I open a popup, I open in fact an HTML page, with image and database access. This is a "normal" page, but has a popup function,, (for example ask the user to conform or cancel an action...)
0
 
Cyber-DrugsCommented:
As long as the popup contains HTML, it can be stored. If you give an example, I could help you out a bit better.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now