[removed] and [removed] is not working in Firefox , Safari , Opera?

后端 未结 6 1897
心在旅途
心在旅途 2020-11-22 12:11

In my chat application I need to get confirmation from user , when my application closes.

So I used the window.onbeforeunload for confirmation alert and

6条回答
  •  不要未来只要你来
    2020-11-22 12:48

    Unfortunately, the methods you are using are unsupported in those browsers. To support my answer (this unsupportive behaviour) I have given links below.

    onbeforeunload and onunload not working in opera... to support this

    onbeforeunload in Opera
    http://www.zachleat.com/web/dont-let-the-door-hit-you-onunload-and-onbeforeunload/

    Though the onunload event doesn't work completely, you can use onunload to show a warning if a user clicks a link to navigate away from a page with an unsaved form.

    onunload not working in safari... to support this

    https://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/

    You could rather try using the pagehide event in the safari browser in lieu of onunload.

    onunload not working in firefox... to support this

    https://bugzilla.mozilla.org/show_bug.cgi?id=681636

    They are yet to come up with a solution in FF too

    Wish you good luck cheers.

提交回复
热议问题