[removed]: Is it possible to get any details about how the window was unloaded?

前端 未结 4 1119
感动是毒
感动是毒 2020-12-16 22:00

I\'m developing one of those warning windows that tells the user that they may have unsaved data, but I only need it to warn them if they\'re leaving the page. Currently it

4条回答
  •  孤街浪徒
    2020-12-16 22:43

    on beforeunload event we can do below things:

    1. We can pass event as a parameter to the function as in above answer. Now we can use this event for available information attached to this event.
    2. And we can access Document level variables.

    For example document.activeElement will give you the last element you clicked that caused the page unload.

    Hope this helps!!

提交回复
热议问题