Leave page reminder feature (enable the reminder feature when the blog garden leaves the editing page)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.