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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing popup with upper right X

Status
Not open for further replies.

dokken

Programmer
Mar 7, 2001
61
0
0
US
I have a popup window that allows the user to edit a record. There is a save and close button on it. The parent page can take a long time to reload. So I want to give them the option to close the window with the Upper Right X and not have it reload. I tried:
function btnClose_OnClick(blnReload) {
opener.popUpWindow = null;
if (blnReload)
window.opener.location=ParentPage.asp?' + Url;
window.close();
}

Then I have:
<BODY onUnload=&quot;javascript:btnClose_OnClick(false);&quot;>
The close button has the following code:
onclick='btnClose_OnClick(true)'

It need to work in both IE 5.0 and NS 4.5 and greater.

Thanks
Paul
 
Is there a reason you are using the onUnload statement to fire that function ?? Remove the onUnload statement and just have your buttons fire that function. That way, closing the window with the X won't trigger any Javascript at all..

Maybe I'm missing something..

TW
 
The reason I want to go thru the unload function is so that I can set the opener.popUpWindow = null;
The reason I do this is so that I can open the window multiple times. Do you have a better way to do this?


function openWindow( windowURL, windowFeatures ) {
//if window exists close it
if (popUpWindow) {
popUpWindow.close();
popUpWindow = null;
}
//set windowName variable to new popup window. This variable is defined in calling page
popUpWindow = window.open(windowURL, &quot;popUpWindow&quot;, windowFeatures );
popUpWindow.focus();
}

 
try

if (popUpWindow && !popUpWindow.closed){

popUpWindow = window.open(windowURL, &quot;popUpWindow&quot;, windowFeatures );
popUpWindow.focus();

}

so, when you'll close this popup, popUpWindow.closed would be true..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top