Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want o update some values if user close browser directly without formal log out.

Could you please guide me for this?


Any help will be grateful..


Thanks in advance.
Posted
Updated 5-Feb-18 20:47pm

1 solution

You can do this using Jquery, in jquery's unload event
 
Share this answer
 
Comments
Vivek Deshmukh 9-Mar-12 8:19am    
Any idea for this ?
Vivek Deshmukh 13-Mar-12 6:07am    
hi,
I have implemented windows.onbeforeunload as.

// Body tag is as
<body önmousedown="BodyClicked()">

window.onbeforeunload = WindowCloseHanlder;
var isClose = false;
function WindowCloseHanlder() {
// alert(document.getElementById('a_TestMe').title);
if (!isClose) {
$.ajax({
type: "GET",
url: "/Account/LogOff" // the URL of the controller action method
});
}
}
function BodyClicked() {
isClose = true;
}

The method LogOff is called only if i close tab but not on direct browser close.

How could i achieve this ?

Please guide me for this...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900