Comparison of JavaScript and JQuery $.alert alert $.confirm confirm

Source: Internet
Author: User

comparison of JavaScript and JQuery pop -up windows

JavaScript has three types of frame objects that are part of the Window object and block the current events and scripts . Subsequent events and scripts are not resumed until the user operation is complete . cannot be used HTML Elements .

jquery (jquery-confirm plugin ) jquery 's popup window is through HTML elements and some JS Events are simulated , are subordinate to the document object , and are not able to block other events and script execution .

example : jQuery Script

Script 1:

var $confirm = $.confirm (' Continue? '); jquery object that returns the current popup after execution Location.reload ()


This script does not wait for the user to click OK before continuing with the following overloaded Operation .

$.confirm just generated a new html element , with CSS control to show the effect of the popup window .

The JS event is then bound on the OK and Cancel buttons , and the callback function is triggered when the user clicks .

The $.confirm task is now complete and will not wait until the user clicks the Confirm or Cancel button to perform the subsequent action .

In this case , The subsequent statements will of course continue to execute , so the page refreshes directly and does not wait for the user to operate .

Script 2:

The actions that need to be determined before they can be performed are placed in the callback function of the popup window to prevent the page from being refreshed when the user is not working .

$.confirm ({title: ' I am the title ', Content: ' Do you want to continue? ', buttons: {confirm:function () {location.reload (        )}, Cancel:function () {$.alert (' canceled! '); }    }});


JavaScript Scripts
var ret=confirm (' Do you want to continue? '); Returns TRUE or Falselocation.reload ()


Confirm a window object that can block the current page until the current page refreshes when the user clicks the Confirm or Cancel button . .

Several pop-up windows of JavaScript

You cannot Customize page presentation using HTML elements .

warning message box (alert)

Pop-up prompt message .

Confirmation message box (confirm)

Pop up a message and Click Confirm to return true Click Cancel to return false

Hint message box (prompt)

Popup input Box , Click Confirm to return the contents of the input box , Click Cancel to return null value

JQuery jquery-confirm

You can use HTML elements to customize pop -up display, and you can use callback functions .

Putting all the script actions into the callback function prevents the page in the example from being refreshed .

https://craftpip.github.io/jquery-confirm/


This article is from the "quxf2012" blog, make sure to keep this source http://quxf2012.blog.51cto.com/12149748/1872114

Comparison of JavaScript and JQuery $.alert alert $.confirm confirm

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.