CopyCode The Code is as follows: Ext. onready (function (){
Ext. msg. Alert ('hprompt ', 'comma-separated parameter list'); // This method is very common
});
:
Copy codeThe Code is as follows: Ext. onready (function (){
// Define JSON (configuration object)
VaR Config = {
Title: 'hup ',
MSG: 'json configuration method, simple'
}
Ext. msg. Show (config );
});
:
I just gave a simple example. Now, I have a pretty interface! Next, let's get to know Ext. messageBox
Ext. messageBox is a tool class inherited from the Obiect object. It is used to generate information prompt dialog boxes of various styles, ext. MSG is the alias of this class. Use Ext. messageBox and ext. MSG works the same, while the latter provides a simpler method. Before the introduction, let's take a look at ext. the difference between the information prompt box provided by MessageBox and the original information prompt box provided by JavaScript is mainly manifested in three aspects, they are "implementation method", "Display Information Format", and "impact on program running", which are described in detail in the following three aspects.
1. Implementation Method:
the information prompt dialog box provided by standard Javascript is a real pop-up window. Ext. the message prompt dialog box provided by MessageBox is not a real pop-up window. It is only a layer (DIV) displayed on the current page ), therefore, you cannot use a window to capture the software.
2. Display Information Format:
the information prompt dialog box provided by standard JavaScript displays plain text instead of HTML text.
you cannot use the formatting method in heml to create a display format. You can only use spaces, carriage returns, and various periods to create a display format.
text displayed in the message prompt dialog box provided by Ext. MessageBox not only supports plain text display, but also supports text in HTML format and formatting in HTML for richer effects. The following is a simple example. copy Code the code is as follows:
:
copy Code the code is as follows: // html text is supported
Ext. onready (function () {
Ext. MSG. alert (' prompt ', ' HTML text supported ');
});
:
Copy codeThe Code is as follows: <SCRIPT type = "text/JavaScript">
Ext. onready (function (){
Alert ('I will stopProgram');
Ext. msg. Alert ('hprompt ',' I won't stop executing the program ');
});
</SCRIPT>
:
Copy codeThe Code is as follows: <SCRIPT type = "text/JavaScript">
Ext. onready (function (){
Ext. msg. Alert ('hprompt ',' I won't stop executing the program ');
Alert ('I will stop executing the program ');
});
</SCRIPT>
:
It's easy to see the results! The following describes how to call back a function. a read-only prompt box is used to replace the Javascript standard alert () method with a confirmation button. if it provides a callback function, the function will be called after the button is clicked (including the push button in the upper right corner). the ID of the clicked button will be passed to the callback function as a unique parameter.
Call format:
Alert (String title, string MSG, [function FN], [object scope]);
// Parameter description
Title: The title of the prompt box.
MSG: information displayed
[Function FN]: (optional) callback function
[Object scopt]: (optional) scope of the callback function
Return Value:
Ext. MessageBox
Example:
Copy codeThe Code is as follows: <SCRIPT type = "text/JavaScript">
Ext. onready (function (){
Ext. MessageBox. Alert ('hprompt ', 'click OK, callback );
Function callback (ID ){
Alert ('click the button ID: '+ id );
}
});
</SCRIPT>
:
Click OK
Click x
Tip: the alert of extjs is asynchronously executed without blocking. Therefore, you must place the code that is executed after confirmation in the callback function, otherwise, subsequent code execution may cause unnecessary errors after the user confirms, which requires our attention.