List Info

Thread: How to capture browser closing event with Javascript




How to capture browser closing event with Javascript
country flaguser name
United States
2007-03-29 20:10:39
Hi all,

Iam trying to capture windows closing event (i.e) when the
user clicks
on the "X" button i want to capture that event and
want to update some
values in the database.I tried two methods but iam getting
problems
with the two methods.

First,one i tried with

function Unload()
    {
         if (window.event.clientX > 0 &&
window.event.clientY < 0)
         {
                 //Browser closing
         }
    }

But this method is called even when the user ic hitting the
back
button or refreshing the page.

Second thing i tried was

function Unload()
    {
        if (window.screenLeft > screen.width)
        {
              //Browser closing
        }
        else
        {
             //Browser refresh
        }
}

This works fine for browser refresh but this method is not
called when
the user closes the browser.

Does any one know how to do this.

Any urgent help will be appreciated.

Thanks in advance.
			{


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "JavaScript Forum" group.
To post to this group, send email to
JavaScript-Informationgooglegroups.com
To unsubscribe from this group, send email to
JavaScript-Information-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/JavaScript-Information
?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: How to capture browser closing event with Javascript
country flaguser name
United States
2007-03-30 08:02:22
i think you are thinking it wrong.

try using

window.onUnload = function() {
//your arguments
}


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "JavaScript Forum" group.
To post to this group, send email to
JavaScript-Informationgooglegroups.com
To unsubscribe from this group, send email to
JavaScript-Information-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/JavaScript-Information
?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )