Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to close the Opened window from the parent

Status
Not open for further replies.

swetab

Programmer
May 6, 2003
49
US
Hello,

I Open new window using window.open to inform the user about saving in progress and once save is done on the parent window I want to close Progress window.

I am not able to close the Progress window its saying Progressbar undefined.

To Open the window:
ProgressBar =window.open("ProgressBar.aspx","Progress","width=170,height=240,left=270,top=180");

To close the window :
function closepopup()
{
if(false == ProgressBar.closed)
{
ProgressBar.close ();
}
else
{
alert('Window already closed!');
}
}

Please help me

Thanks.
 
Are you defining ProgressBar in the same place as you are trying to close it? Is ProgressBar a global variable, or was it defined within a function?

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
ahh, good point.

yes, make sure you have, at the top of your page (between <head></head>), this:

Code:
<script type="text/javascript"><!--
var ProgressBar;
//--></script>

*cLFlaVA
----------------------------
[tt]your mom goes to college[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Hello,

No luck its still sating ProgressBar is undefined.

I think its because the parent window has lost the reference??

let me know if there is any other way to do it please..

Thanks
 
Now its giving PrgressBar.closed is null or not an object.

 
Ok here is the code:

On Page load event of aspx.vb page to open the progress window:
cmdSave.Attributes.Item("onclick") = "this.disabled=true;cmdApprove.disabled=true;cmdDeny.disabled=true;Show_Progress();" & GetPostBackEventReference(cmdSave).ToString

In html page have 2 JS function one for open and other to close:
function Show_Progress()
{
ProgressBar =window.open("ProgressBar.aspx","ProgressBar","width=170,height=240,left=270,top=180");

}

function closepopup()
{

if(false == ProgressBar.closed)
{
ProgressBar.close ();
}
else
{
alert('Window already closed!');
}
}

Close is called after save button click event is done like this :
Page.RegisterStartupScript("Progress", "<script> closepopup(); </script>")
 
Add this right before your Show_Progress() function:
Code:
var ProgressBar = {closed:true}

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
And by "before" I mean "above" it.

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
Hi Adam, it didn't work !

I found the solution myself and it worked:
Page.RegisterStartupScript("Progress", "<script> Show_progress();closepopup(); </script>")

Thanks for the support.

 
Wouldn't that just flash the popup for a split second then close it right away?

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
Nevermind, I see what you are doing. You are performing a post-back, so the reference is getting lost. It looks like you already found out how to restablish the link to the popup. Good work. The code I gave you should still be used though to make sure the ProgressBar variable is global.

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
Another option that I've used for a progress bar on IE-only apps is to use the showModelessDialog() method which closes automatically when the page unloads.

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top