Solved

Javascript reopening popup

Posted on 2007-04-11
7
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…
Suggested Courses

738 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