JavaScript question: Onbeforeunload or Onunload?

后端 未结 4 556
一整个雨季
一整个雨季 2020-12-05 07:47

So I want to store some information in localstorage of a browser when the page is refreshed or the user exits the page for future use. I figured that I\'d use some Javascrip

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 08:31

    I believe that Onbeforeunload is a safe bet. It is possible for browser to not execute onunload script completely - for example, if you have alert in onunload, chrome would not show if you close the window.

提交回复
热议问题