0

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

  1. Using MS-VS 2010
  2. MS-SQL 2010
  3. C#
  4. 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

Edited by Dani: Formatting fixed

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by shakeb@techwave
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.