PC Review


Reply
Thread Tools Rate Thread

How to detect user's intention when onunload fires?

 
 
feng
Guest
Posts: n/a
 
      29th Feb 2004
I want to use onunload to capture user's action when he
clicks on the "x" button to close the browser. Here is how
I do this:
<SCRIPT FOR="window" EVENT="onunload">
myScript();
</SCRIPT>

While myScript() does get called when "x" gets clicked, it
is also get called when the user leaves the current page
and navigate to another page within our web application.
My question is how do I determin if onunload is fired
because of an "x" clicking, an attempt to go out of
current web application, or simply go to another page
within our application.

Any input will be highly appreciated.

Thanks

Lifeng
 
Reply With Quote
 
 
 
 
Jim Brandley
Guest
Posts: n/a
 
      29th Feb 2004
Try adding some more script.
1. Add a startup script that defines a variable and initializes it to some
value.
2. Add an onClick event handler to "x", and in it, change the value.
3. Inside myScript(), conditionally execute the content, depending on the
value of the variable.

Hope that helps.

"feng" <(E-Mail Removed)> wrote in message
news:43ff01c3feea$802f9430$(E-Mail Removed)...
> I want to use onunload to capture user's action when he
> clicks on the "x" button to close the browser. Here is how
> I do this:
> <SCRIPT FOR="window" EVENT="onunload">
> myScript();
> </SCRIPT>
>
> While myScript() does get called when "x" gets clicked, it
> is also get called when the user leaves the current page
> and navigate to another page within our web application.
> My question is how do I determin if onunload is fired
> because of an "x" clicking, an attempt to go out of
> current web application, or simply go to another page
> within our application.
>
> Any input will be highly appreciated.
>
> Thanks
>
> Lifeng



 
Reply With Quote
 
feng
Guest
Posts: n/a
 
      29th Feb 2004
Thanks for the reply.

"Add an onClick event handler to 'x'"? How do you do that?
If this is possible, that would be a perfect solution to
my problem.

Do you know how to do that? Can you show me?

Thanks

>-----Original Message-----
>Try adding some more script.
>1. Add a startup script that defines a variable and

initializes it to some
>value.
>2. Add an onClick event handler to "x", and in it, change

the value.
>3. Inside myScript(), conditionally execute the content,

depending on the
>value of the variable.
>
>Hope that helps.
>
>"feng" <(E-Mail Removed)> wrote in

message
>news:43ff01c3feea$802f9430$(E-Mail Removed)...
>> I want to use onunload to capture user's action when he
>> clicks on the "x" button to close the browser. Here is

how
>> I do this:
>> <SCRIPT FOR="window" EVENT="onunload">
>> myScript();
>> </SCRIPT>
>>
>> While myScript() does get called when "x" gets clicked,

it
>> is also get called when the user leaves the current page
>> and navigate to another page within our web application.
>> My question is how do I determin if onunload is fired
>> because of an "x" clicking, an attempt to go out of
>> current web application, or simply go to another page
>> within our application.
>>
>> Any input will be highly appreciated.
>>
>> Thanks
>>
>> Lifeng

>
>
>.
>

 
Reply With Quote
 
Jim Brandley
Guest
Posts: n/a
 
      29th Feb 2004
Something like this, depending on what your "X" is:

myButton.Attributes["OnClick"] = "javascript: if ( myClickVar != null){
myClickVar = 'Clicked'; };";



"feng" <(E-Mail Removed)> wrote in message
news:446601c3fef8$9ba9b200$(E-Mail Removed)...
> Thanks for the reply.
>
> "Add an onClick event handler to 'x'"? How do you do that?
> If this is possible, that would be a perfect solution to
> my problem.
>
> Do you know how to do that? Can you show me?
>
> Thanks
>
> >-----Original Message-----
> >Try adding some more script.
> >1. Add a startup script that defines a variable and

> initializes it to some
> >value.
> >2. Add an onClick event handler to "x", and in it, change

> the value.
> >3. Inside myScript(), conditionally execute the content,

> depending on the
> >value of the variable.
> >
> >Hope that helps.
> >
> >"feng" <(E-Mail Removed)> wrote in

> message
> >news:43ff01c3feea$802f9430$(E-Mail Removed)...
> >> I want to use onunload to capture user's action when he
> >> clicks on the "x" button to close the browser. Here is

> how
> >> I do this:
> >> <SCRIPT FOR="window" EVENT="onunload">
> >> myScript();
> >> </SCRIPT>
> >>
> >> While myScript() does get called when "x" gets clicked,

> it
> >> is also get called when the user leaves the current page
> >> and navigate to another page within our web application.
> >> My question is how do I determin if onunload is fired
> >> because of an "x" clicking, an attempt to go out of
> >> current web application, or simply go to another page
> >> within our application.
> >>
> >> Any input will be highly appreciated.
> >>
> >> Thanks
> >>
> >> Lifeng

> >
> >
> >.
> >



 
Reply With Quote
 
feng
Guest
Posts: n/a
 
      29th Feb 2004
Oh no, the "x" is not myButton. It is the "x" button on
the upper-right corner of browser window. I don't think
you can "add a click event handler" to that, can you?

Thanks

>-----Original Message-----
>Something like this, depending on what your "X" is:
>
>myButton.Attributes["OnClick"] = "javascript: if (

myClickVar != null){
>myClickVar = 'Clicked'; };";
>
>
>
>"feng" <(E-Mail Removed)> wrote in

message
>news:446601c3fef8$9ba9b200$(E-Mail Removed)...
>> Thanks for the reply.
>>
>> "Add an onClick event handler to 'x'"? How do you do

that?
>> If this is possible, that would be a perfect solution to
>> my problem.
>>
>> Do you know how to do that? Can you show me?
>>
>> Thanks
>>
>> >-----Original Message-----
>> >Try adding some more script.
>> >1. Add a startup script that defines a variable and

>> initializes it to some
>> >value.
>> >2. Add an onClick event handler to "x", and in it,

change
>> the value.
>> >3. Inside myScript(), conditionally execute the

content,
>> depending on the
>> >value of the variable.
>> >
>> >Hope that helps.
>> >
>> >"feng" <(E-Mail Removed)> wrote in

>> message
>> >news:43ff01c3feea$802f9430$(E-Mail Removed)...
>> >> I want to use onunload to capture user's action when

he
>> >> clicks on the "x" button to close the browser. Here

is
>> how
>> >> I do this:
>> >> <SCRIPT FOR="window" EVENT="onunload">
>> >> myScript();
>> >> </SCRIPT>
>> >>
>> >> While myScript() does get called when "x" gets

clicked,
>> it
>> >> is also get called when the user leaves the current

page
>> >> and navigate to another page within our web

application.
>> >> My question is how do I determin if onunload is fired
>> >> because of an "x" clicking, an attempt to go out of
>> >> current web application, or simply go to another page
>> >> within our application.
>> >>
>> >> Any input will be highly appreciated.
>> >>
>> >> Thanks
>> >>
>> >> Lifeng
>> >
>> >
>> >.
>> >

>
>
>.
>

 
Reply With Quote
 
Jim Brandley
Guest
Posts: n/a
 
      29th Feb 2004
Not that I'm aware of.
"feng" <(E-Mail Removed)> wrote in message
news:44c401c3fefe$3b8758e0$(E-Mail Removed)...
> Oh no, the "x" is not myButton. It is the "x" button on
> the upper-right corner of browser window. I don't think
> you can "add a click event handler" to that, can you?
>
> Thanks
>
> >-----Original Message-----
> >Something like this, depending on what your "X" is:
> >
> >myButton.Attributes["OnClick"] = "javascript: if (

> myClickVar != null){
> >myClickVar = 'Clicked'; };";
> >
> >
> >
> >"feng" <(E-Mail Removed)> wrote in

> message
> >news:446601c3fef8$9ba9b200$(E-Mail Removed)...
> >> Thanks for the reply.
> >>
> >> "Add an onClick event handler to 'x'"? How do you do

> that?
> >> If this is possible, that would be a perfect solution to
> >> my problem.
> >>
> >> Do you know how to do that? Can you show me?
> >>
> >> Thanks
> >>
> >> >-----Original Message-----
> >> >Try adding some more script.
> >> >1. Add a startup script that defines a variable and
> >> initializes it to some
> >> >value.
> >> >2. Add an onClick event handler to "x", and in it,

> change
> >> the value.
> >> >3. Inside myScript(), conditionally execute the

> content,
> >> depending on the
> >> >value of the variable.
> >> >
> >> >Hope that helps.
> >> >
> >> >"feng" <(E-Mail Removed)> wrote in
> >> message
> >> >news:43ff01c3feea$802f9430$(E-Mail Removed)...
> >> >> I want to use onunload to capture user's action when

> he
> >> >> clicks on the "x" button to close the browser. Here

> is
> >> how
> >> >> I do this:
> >> >> <SCRIPT FOR="window" EVENT="onunload">
> >> >> myScript();
> >> >> </SCRIPT>
> >> >>
> >> >> While myScript() does get called when "x" gets

> clicked,
> >> it
> >> >> is also get called when the user leaves the current

> page
> >> >> and navigate to another page within our web

> application.
> >> >> My question is how do I determin if onunload is fired
> >> >> because of an "x" clicking, an attempt to go out of
> >> >> current web application, or simply go to another page
> >> >> within our application.
> >> >>
> >> >> Any input will be highly appreciated.
> >> >>
> >> >> Thanks
> >> >>
> >> >> Lifeng
> >> >
> >> >
> >> >.
> >> >

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New WLM intention Peter in New Zealand Windows Vista Mail 10 19th Jun 2007 03:36 AM
user control dispose never fires =?Utf-8?B?VGltIFJhbWw=?= Microsoft Dot NET Compact Framework 3 6th Aug 2005 01:25 AM
Trapping the <BODY> onUnload() / Detecting when a user closes the browser =B= Microsoft ASP .NET 3 30th Sep 2004 09:20 AM
Determin user's intention when onunload fires feng Microsoft ASP .NET 0 29th Feb 2004 08:19 PM
Only first user control event fires. Jason Chancellor Microsoft ASP .NET 0 15th Feb 2004 02:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:40 AM.