Closing popup

B

Brian Mitchell

Hello,

I have an aspx app that executes the window.open to open a popup windows,
but is there an easy way to close the popup? (I can't find a window.close
method)

Thanks!
 
D

Darrin J Olson

Last time I needed to do this, this is how I did it. I think it should still
work.

When you pop-up your window, assign the window.open function to a variable:

var childWin;
childWin = window.open('newwindow.htm', 'PopUp', etc....);


Then, when you need to close it, (I'm assuming from the parent window that
opened it in the first place):

if(childWin && !childWin.closed) //make sure it is not null, and it is not
already closed.
{
childWin.close();
}


-Darrin
 
B

Brian Mitchell

I'm sorry, I should have specified that there is a button in the child
window that will close it. The parent won't be doing it.

Thanks!
 
D

Darrin J Olson

Oh, sorry man. Kinda' went overboard there.

There is a window.close() method to close the window. I assumed you were
doing a child window since you had mentioned the window.close below! :)

In your OnClick event for the button, do:

window.close();

-Darrin
 
B

Brian Mitchell

Yeah, that did it. Thanks for the help!!

I didn't see a window.close method in my help so I just assumed it was't
available.

Thanks again!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top