Browser Crash Handler

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    Browser Crash Handler

    Hi,
    Is there any event listener or window listener for Browser Crash event other than onUnload? Is there any way to call a JS function when an application or system is crashed?

    Regards
    Ramanan Kalirajan
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    when a system crashes it usually doesn't execute anything until reloaded… (in FF there may be a setting available where the crash status is given so you can execute something on reload)

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      I don't think so, though you could probably write browser-specific code to deal with a "crash" event. What kind of function would you want to run?

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        In my application I am maintaining the user details in session. When the browser crashes the facilities must be released for that only. Previously i tried with onUnload in body it works in IE but not in Mozilla, due to Security issues they have prevented executing onunload. Then thought of using onbeforeunload listener but there are some drawbacks in using them such as, it allways prompts a confirmation msg, It is triggered even when the page is refreshed. Is there any suggestion regarding this..... Thanks in advance.

        Regards
        Ramanan Kalirajan

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Is there any reason why you want to invalidate the session? You can set a timeout of 20 minutes or half an hour.

          Comment

          • RamananKalirajan
            Contributor
            • Mar 2008
            • 608

            #6
            Ya I have set that thing. But I want to know wether there is any possibility to handle this condition.

            Regards
            Ramanan Kalirajan

            Comment

            • acoder
              Recognized Expert MVP
              • Nov 2006
              • 16032

              #7
              Not that I'm aware of, cross-browser, at least. If the browser does crash and the page is reloaded and the session continues, what's the harm?

              Comment

              • RamananKalirajan
                Contributor
                • Mar 2008
                • 608

                #8
                The harm is that, for each and every user will be provided with a Order ID & PON no. dynamically whenever he login to the application, those information will be stored in the DB. Without completing an order if the customer logout means we will be releasing that order id, pon and assign that to some other user. This should occur when the system crashes also. I used onBeforeUnload it was showing a prompt message even the page is refreshed and navigated to other page. In IE I used mouse click event to trace wether the user is clicking the browser close button with the PageX, PageY it was working in IE but not in mozilla due to the ClientWidth & ClientHeight are different in IE and Mozilla. I just wanted to find out wether there is any other JS function would work during the browser close event/Browser Crash. Thanks for all of ur suggestion.

                Thanks & Regards
                Ramanan Kalirajan

                Comment

                • acoder
                  Recognized Expert MVP
                  • Nov 2006
                  • 16032

                  #9
                  I understand, but if the user immediately restarts the browser and continues the session, it's the same as staying a minute or so on one page.

                  Comment

                  • RamananKalirajan
                    Contributor
                    • Mar 2008
                    • 608

                    #10
                    Yes.. That cant be done....

                    Regards
                    Ramanan Kalirajan

                    Comment

                    • pronerd
                      Recognized Expert Contributor
                      • Nov 2006
                      • 392

                      #11
                      Originally posted by RamananKaliraja n
                      When the browser crashes the facilities must be released for that only.
                      This is something that needs to be done on the server side. The client side not reliable enough to carry out critical funcitons. There are too many knowns. Difffernt browser bugs, differnt browser plugins that can change behaviors, different browser security settings that can prevent JavaScript features etc. etc. This also would not handle the problem of OS level crashes, or loss of network connectivity. The server side logic needs to handle critical functions like this. Why are you assigning order numbers to people as soon as they login? That seems to be the core issue. Most systems do not assign an order number until the user places an order, and are able to avoid this problem.

                      Comment

                      • RamananKalirajan
                        Contributor
                        • Mar 2008
                        • 608

                        #12
                        Thanks for your suggestion.


                        Regards
                        Ramanan Kalirajan

                        Comment

                        • sarwar786
                          New Member
                          • Jun 2018
                          • 1

                          #13
                          Were you ever able to figure this out?
                          I have the same problem now but i am not able to find any useful solution.

                          Thanks

                          Comment

                          • gits
                            Recognized Expert Moderator Expert
                            • May 2007
                            • 5388

                            #14
                            Browser Crash:

                            well - it is impossible with javascript - javascript "runs on the webpage" - if the browser crashes the javascript-program crashes with it naturally. so the application has to be implemented in a way that such cases wouldn't hurt - thus it would avoid the need of a solution to solve an issue that a webpage/-application shouldnt even need to take care of.

                            Intentionally leave the page:

                            use either this:

                            The beforeunload event is fired when the current window, contained document, and associated resources are about to be unloaded. The document is still visible and the event is still cancelable at this point.


                            or this:

                            The unload event is fired when the document or a child resource is being unloaded.


                            note that both events are not exactly the same and should be used depending on what real behaviour is to be implemented.

                            Option to have better information about Clientstate at the server to react there somehow

                            by not using normal http requests but websockets for example to communicate between server and client - its possible to receive a 'disconnect-event' at the server - which can be handled respectivly then.
                            Last edited by gits; Aug 27 '18, 08:21 AM. Reason: split answer into 2 parts crash/intentional leave - add info on how to have more control if needed

                            Comment

                            Working...