Home > Article > Web Front-end > Examples of six interactive methods commonly used in JavaScript_javascript skills
1.confirm message dialog box
Syntax: confirm("str");
Parameter description: str is the text to be displayed in the dialog box,
Function: It is usually used to remind the user to make certain choices. The return value is a Boolean type. Click to confirm and the return value is true. Click to cancel and the return value is false
For example:
2.prompt message dialog box
Syntax: prompt("str1","str2");
Parameter description: str1 is the text to be displayed in the dialog box and cannot be modified; str2 is the content in the text box and can be modified
Function: Pop up a dialog box to ask for information about interacting with the user
For example:
3.window.openopen new window
Syntax: window.open('str1','str2','str3');
Parameter description: str1 is the address of the window to be opened; str2 is the name of the window to be opened; str3 is the parameter to control the window
Function: Open a new window
For example:
4.window.closeClose new window
Syntax: window.close('str'); or
Parameter description: str is the address of the open window
For example:
5.alert warning
Syntax: alert("str");//note the double quotes
Parameter description: str is the content of the dialog box pop-up
For example:
6.document.write output content
Syntax: document.write("str")
Function: Output text str
For example:
The above six points are all the content shared with you in this article. I hope you will like it.