Bring popup window to front if already open

Be it ASP.NET, PHP or JavaScript, here you can discuss the code that empowers your websites, give help and get help.

Bring popup window to front if already open

Postby Harpy on 13 Nov 2007, 02:54

I have a popup window that gets open by a button. If the popup loses focus or gets behind other windows and the user clicks Open again, I want the window brought back to focus. I must be doing something wrong because it's not working (in both IE and FF.) :cry:

Anyone care to lend a hand?
User avatar
Harpy
 
Posts: 6
Joined: 10 Nov 2007, 11:45

Re: Bring popup window to front if already open

Postby Andrew on 13 Nov 2007, 14:49

I just used this piece of code very recently and it does exactly what you said:

Code: Select all
function ShowPopup()
{

   if(InfoPopup && !InfoPopup.closed)
   {
      InfoPopup.focus();
   }
   else
   {
      InfoPopup= window.open(Info.php', 'InfoPopup', 'status=1,height=500,width=700,resizable=0,scrollbars=1');
   }
}
Andrew
Site Admin
 
Posts: 19
Joined: 04 Nov 2007, 15:30
Location: New York City

Re: Bring popup window to front if already open

Postby Harpy on 16 Nov 2007, 03:44

Thanks man... exactly what I needed.
User avatar
Harpy
 
Posts: 6
Joined: 10 Nov 2007, 11:45


Return to Coding

Who is online

Users browsing this forum: No registered users and 0 guests

cron