Home >Web Front-end >JS Tutorial >Monitor whether the user closes the browser's js code_javascript skills

Monitor whether the user closes the browser's js code_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:47:49910browse

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]

The effect is as follows:

When wonder.event.returnValue is empty, this selection prompt box will not appear.


But the question comes again: If I want the user to be able to save user-related data when he clicks the "OK" button to close the browser. So what should I do?

It seems that the only way is to use the onunload parameter.


Modify the above code as follows:


[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute ]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn