www.webdeveloper.com
Results 1 to 4 of 4

Thread: Using javascript - On browser close event i need to update my database

  1. #1
    Join Date
    May 2012
    Posts
    2

    Using javascript - On browser close event i need to update my database

    Hai,

    Using javascript, I need to update my database on browser close event
    Im able to do it with IE but mozilla firefox does return undefined alwz for event.pageX property

    <script>
    function closeWindow(e)
    {
    var evtobj=window.event? event : e;

    if(evtobj == e)
    {

    //firefox
    // alert(e.clientX + ' * ' + e.clientY); You will find both the value is undefined.
    if (evtobj.pageY)
    {
    alert("Your session gets invalidated");

    }
    }
    else
    {

    //IE
    //alert(e.clientX + ' * ' + e.clientY); The value will be your mouse last position.
    if (evtobj.clientY < 0)
    {

    alert("Your session gets invalidated");

    }


    }
    }
    </script>


    In body tag iam calling this function like below

    <body onbeforeunload="closeWindow(event);">


    In IE - evtobj.clientY is properly getting executed
    My problem is in firefox, always returns undefined for evtobj.pageY
    can anybody help me in fixing this issue

    Thanks

  2. #2
    Join Date
    Nov 2006
    Location
    Oakland
    Posts
    500
    I am not sure if the code in your function was written to perform the task mentioned: "Using javascript - On browser close event i need to update my database"

    function closeWindow(){
    //perform the task at hand here.

    }

    I do not see the point of using the event "e" here because you already know what triggered the function closeWindow(). Al yiu have to do is write the database update statements.

  3. #3
    Join Date
    May 2012
    Posts
    2
    Hai,

    Thanks. Im able to do as you have said.
    But can you tell me why evtobj.pageY returns undefined always in my above code

    Thanks

  4. #4
    Join Date
    Jun 2012
    Posts
    2
    I would suggest using this new JSON Data site. It is in beta now but will allow you to update things in real time and it's free! Hope this helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles