Browser Close Event - Javascript
This is a discussion on Browser Close Event - Javascript ; 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 ...
-
Browser Close Event
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.
-
Re: Browser Close Event
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/
-
Re: Browser Close Event
On Apr 26, 3:05 am, Randy Webb <HikksNotAtH...@aol.com> wrote:
> 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.
-
Re: Browser Close Event
bsm said the following on 4/26/2007 6:06 AM:
> On Apr 26, 3:05 am, Randy Webb <HikksNotAtH...@aol.com> wrote:
>> 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/
-
Re: Browser Close Event
On Apr 28, 2:04 am, Randy Webb <HikksNotAtH...@aol.com> wrote:
> bsm said the following on 4/26/2007 6:06 AM:
>
>
>
>
>
> > On Apr 26, 3:05 am, Randy Webb <HikksNotAtH...@aol.com> wrote:
> >> 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.
Similar Threads
-
By Application Development in forum Adobe Acrobat
Replies: 0
Last Post: 03-08-2007, 07:53 PM
-
By Application Development in forum Java
Replies: 1
Last Post: 05-03-2004, 07:01 PM
-
By Application Development in forum Javascript
Replies: 3
Last Post: 10-22-2003, 05:38 AM
-
By Application Development in forum Java
Replies: 2
Last Post: 07-29-2003, 10:50 AM
-
By Application Development in forum Microsoft Exchange
Replies: 0
Last Post: 07-10-2003, 02:58 PM