Solved

Javascript reopening popup

Posted on 2007-04-11
7
360 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…

813 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

11 Experts available now in Live!

Get 1:1 Help Now