With JS How to judge I have clicked the "Close" button in the form?

Source: Internet
Author: User

The onbeforeunload event is triggered when it is about to leave the current page (refresh or close).

This event can be used to pop up a dialog box that prompts the user to continue browsing the page or leave the current page.

The default message for the dialog box differs depending on the browser, and the standard information is similar to "Are you sure you want to leave this page?" "。 This information cannot be deleted.

But you can customize some message prompts to appear in the dialog box along with the standard information.

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><title>Beginner's Tutorial (runoob.com)</title></Head><Body><P>Close the current window, press F5 or click the following link to contact the onbeforeunload event.</P><ahref= "Http://www.runoob.com">Click to jump to rookie tutorial</a>    <Script>Window.onbeforeunload= function(e) {return(e||window.event). ReturnValue= 'have information not saved, confirm leave?! '; }</Script></Body></HTML>

With JS How to judge I have clicked the "Close" button in the form?

Related Article

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.