Javascript-js window escape effect

Source: Internet
Author: User
To create a background, edit the article function, and product requirements, when the user clicks the edit window and does not save the changes, click any place other than the edit window to prevent default events, the pop-up window allows you to select whether to save and then execute the default event. There is no good solution if you want to come and try again... to create a background, edit the article function, and product requirements, when the user clicks the edit window and does not save the changes, click any place other than the edit window to prevent default events, the pop-up window allows you to select whether to save and then execute the default event.
There is no good solution if you want to come and try again.

The main problem is not to close the browser trigger dialog box, but to trigger when you click the non-edit window part on the page, which contains various binding events, links, and so on.

Reply content:

To create a background, edit the article function, and product requirements, when the user clicks the edit window and does not save the changes, click any place other than the edit window to prevent default events, the pop-up window allows you to select whether to save and then execute the default event.
There is no good solution if you want to come and try again.

The main problem is not to close the browser trigger dialog box, but to trigger when you click the non-edit window part on the page, which contains various binding events, links, and so on.

The original idea was to add a defocus event to the editing window. the custom confirm was displayed. based on the choice of confirm, the default event was executed and the result was abandoned...
At last, you can only add judgment methods for each link and event, and pass in the default execution function as the callback parameter.
Similar to this

Homepage

Change

Are you sure you want to leave?

YesNo

Homepage script $ ('A '). click (function () {myconfirm (function () {window. location. href = "index. php ";}, function () {return false ;}); function myconfirm (fun_yes, fun_no) {$ ('# yes '). unbind (); $ ('# no '). unbind (); $ ('# yes '). click (function () {fun_yes () ;}); $ ('# no '). click (function () {fun_no () ;}); $ ('# myconfirm '). show ();} script

A popular dialog box plug-in,
Http://aui.github.io/artDialo...

Listen to browser close events

Can't I bind an onblur event to the editor?

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.