Solved

Javascript reopening popup

Posted on 2007-04-11
7
359 Views
Last Modified: 2008-03-06
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
Comment
Question by:vinceTrace
  • 3
  • 2
7 Comments
 
LVL 4

Expert Comment

by:Cyber-Drugs
ID: 18890232
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
 

Author Comment

by:vinceTrace
ID: 18890268
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
 
LVL 4

Accepted Solution

by:
Cyber-Drugs earned 75 total points
ID: 18890382
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
 

Author Comment

by:vinceTrace
ID: 18890615
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
 
LVL 4

Expert Comment

by:Cyber-Drugs
ID: 18890882
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now