Browser Close Event

B

bsm

Hi,

I have googled for my issue in this group. This question was asked
many times and many solution was given. But I want clear cut solution
for the issue.

The issue is:

I tried to capture the browse close event by using
Body onunload=fn1() statement and it is working fine.

I have one Parent and child window.
My req is to close the child window when I click -X- buton in IE. It
is also working fine. (I wrote condition in Unload event of the parent
page).

But when the page is postback (when I click one button) the unload
event fires and it closes my child window automatically. But I want my
child window should not close this situation.

How this can be achieved.

Thanks in advance.
 
B

bsm

bsm said the following on 4/25/2007 6:08 AM:











Then have the button you click set a parameter. The fn1 function would
check that parameter and either close or not close the window.

<button onclick="closeWindow=false;someFunction()">My Button</button>

function fn1(){
if (closeWindow){window.close()}else{
closeWindow = true;

}
}

I will leave it to you to figure out why the closeWindow=true is in the
fn1 function.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/- Hide quoted text -

- Show quoted text -

Thanks, I understood why you have given closewindow=true. I am
developing dotnet web page. there i have used this technique. When I
click IE "X" button. it fires well. But When I click any button. It
fires Page_OnUnload event automatically. That's my issue.
 
B

bsm

bsm said the following on 4/26/2007 6:06 AM:








Totally irrelevant.


Which technique?


The unload event?


Then there is code somewhere calling that function.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/- Hide quoted text -

- Show quoted text -
From Javascript point of view this snipet is fine. Let me post this
issue in dotnet group.

Thanks a lot Randy.
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top