473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Browser Close Event

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.

Apr 25 '07 #1
4 6064
bsm said the following on 4/25/2007 6:08 AM:
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.
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/
Apr 25 '07 #2
bsm
On Apr 26, 3:05 am, Randy Webb <HikksNotAtH...@aol.comwrote:
bsm said the following on 4/25/2007 6:08 AM:


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.

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.

Apr 26 '07 #3
bsm said the following on 4/26/2007 6:06 AM:
On Apr 26, 3:05 am, Randy Webb <HikksNotAtH...@aol.comwrote:
>bsm said the following on 4/25/2007 6:08 AM:


>>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.
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.
<snipped quoted signature that Google Groups can't remove>
Thanks, I understood why you have given closewindow=true.
OK.
I am developing dotnet web page.
Totally irrelevant.
there i have used this technique.
Which technique?
When I click IE "X" button. it fires well.
The unload event?
But When I click any button. It fires Page_OnUnload event automatically.
That's my issue.
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/
Apr 27 '07 #4
bsm
On Apr 28, 2:04 am, Randy Webb <HikksNotAtH...@aol.comwrote:
bsm said the following on 4/26/2007 6:06 AM:


On Apr 26, 3:05 am, Randy Webb <HikksNotAtH...@aol.comwrote:
bsm said the following on 4/25/2007 6:08 AM:
>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.
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.

<snipped quoted signature that Google Groups can't remove>
Thanks, I understood why you have given closewindow=true.

OK.
I am developing dotnet web page.

Totally irrelevant.
there i have used this technique.

Which technique?
When I click IE "X" button. it fires well.

The unload event?
But When I click any button. It fires Page_OnUnload event automatically.
That's my issue.

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.

May 2 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: hawkon | last post by:
Hi all, I have an important question to ask about how to trap events when the user close the browser window. I'm a ASP programmer and I have s MSSQL database with a user table where I'm able to...
1
by: Matt | last post by:
When we refresh the page (F5, or icon in browser), it will first trigger ONUNLOAD event and then trigger ONLOAD event. When we close the browser (X on right top icon), it will trigger ONUNLOAD...
3
by: Bond | last post by:
how do I know when the browser is making a request to the server? I am not having an onclick event for EVERY hyperlink, submit, etc. There must be some javascript function that I can overwrite...
3
by: Denon | last post by:
How to trap browser close event in SERVER side? I read a lot of forum message, it talk about onclose(), onunload() and even onbeforeunload() event. However, all of theses are based on javascript...
3
by: =B= | last post by:
Hi all, I was wondering if anyone has had any luck with trapping the <BODY> onUnload() event in ASP.NET? The thing is, I'm writing code for an Intranet site. The code makes a call to a...
4
by: Bill Manring | last post by:
I need to capture the event when the user closes the browser in my application. I have some code in the session_End event, which works fine when the session times out, but I need to end the...
6
by: hemant.singh | last post by:
Hi all, I am trying to get a way by which I'll know exactly when user goes out of my site by clicking on close button in browser, So that w/e user click close button in browser, I can send a...
1
by: baburk | last post by:
Hi, I wants to capture browser tab close event? I got for window close event. if((window.event.clientX<0) || (window.event.clientY<0)) { }
3
by: Gouri.Mahajan7 | last post by:
Hello, I am new to asp.net. Can anybody please tell me which event is fired when we close the browser. I want to remove some resources when the browser close button is pressed. Thanks in advance....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.