I am a new software developer.I am developing a website which required to maintain log-in and log-out time of the user.I can maintain my database when user click on Log-out button but i can not track the user when he click on Browser Close X(or in Tab Close)event.I also want to trap ALT+F4 event or any other Event for updating database. I hope Code will work in all type of browser not for IE Only.Please help me ASAP
- Using MS-VS 2010
- MS-SQL 2010
- C#
- JavaScript
Currently i am using this code in JavaScript which Update Database every time on Page-load and page-refresh event which not required. Code Should update Data Base when browser is Close by user and I am also maintaining in database Login-Logout time in Global.asax file on session _End event.
var clicked = false;
window.onunload = function () {
if (clicked == false) {
//Browser closed
var returnCode = GetRequest();
}
else {
//redirected
clicked = false;
}
}
function bodyUnload() {
if (clicked == false)//browser is closed
{
var request = GetRequest();
request.open("GET", "../Testingpage.aspx?LogoffDatabase=Y", true);
request.send();
}
//
<body Onclick="clicked = True">
//
//Updating Data Base with Server site code
]With Regard
Shakeb Khan