Friends who have used the blog garden may know that when we are editing, we want to leave this page (whether you click the cross in the upper right corner of the browser or click any link on the page, or when minimized, right-click and close) will be a reminder to leave the function! It is often a protection for all the content written when users accidentally leave the page! As follows:
I have asked a friend on the Internet. I will publish one here!
Of course, the client function is implemented by Js!
CodeAs follows:
< Html >
< Script Language = Javascript >
Function Stoprefresh ()
{
Return "You will lose any unsaved content";
}
Function Unloadconfirm ()
{//Events after page exit
Alert ('some cleanup work after leaving the page ...... ');
}
</ Script >
< Body >
< Script >
Window. onbeforeunload = Stoprefresh; // Events Before closing Registration
Window. onUnload = Unloadconfirm; // Events after registration is closed
</ Script >
< A Href = "Http://eflylab.cnblogs.com" > Go to the Chu Xuan blog </ A >
</ Body >
</ Html >
Effect:
This function is quite practical. It cannot be captured only when the browser process ends in the task manager!
However, the essence of this function is to remind users of the loss caused by accidentally leaving the editing page,
Force stop the process by yourself.