1.confirm message dialog box
Syntax: Confirm ("str");
Parameter description: STR is the text to be displayed in the dialog box,
Function: Usually to remind the user to make certain choices, its return value is Boolean type, click OK return value is ture, click Cancel return value is False
For example:
<script type= "Text/javascript" > var mymessage=confirm ("Do you like JavaScript?"); if (mymessage==true) { document.write ("Very good, come on!"); } else { document.write ("JS powerful, to learn Oh!"); } </script>
2.prompt message dialog box
Syntax: Prompt ("str1", "str2");
Parameter description: STR1 is the text to be displayed in the dialog box, cannot be modified, STR2 is the contents of the text box, you can modify
Role: Pop up a dialog box asking for information about interacting with the user
For example:
var myname=prompt ("Please enter your name:");
if (myname!=null) { alert ("Hello" +myname);} else { alert ("Hello my friend.");
3.window.open Opening a new window
Syntax: window.open (' str1 ', ' str2 ', ' str3 ');
Parameter description: STR1 is the address of the window you want to open; str2 is the name of the window you want to open; STR3 is the parameter of the control window
Role: Open a new window
For example:
<script type= "Text/javascript" >
window.open (' http://www.imooc.com ', ' _blank ', ' width=300,height=200,menubar=no,toolbar=no, status=no,scrollbars= Yes ') </script>
4.window.close Close a new window
Syntax: window.close (' str '), or < new window >.close ();
Parameter description: STR is the address of the open window
For example:
<script type= "Text/javascript" > var mywin=window.open (' http://www.imooc.com ');//The newly-hit window object, stored in the variable Mywin mywin.close ();</script>
5.alert Warning
Syntax: alert ("str");//note is double quotation marks
Parameter description: What str pops up for the dialog box
For example:
<script type= "Text/javascript" > var mynum = 30; Alert ("hello!"); Alert (mynum);</script>
6.document.write Output Content
Syntax: document.write ("str")
Function: Output text str
For example:
</pre><pre name= "Code" class= "JavaScript" ><script type= "Text/javascript" > document.write ("I Love javascript! "); Content is output directly from the content in "", "". </script>
Common methods of interaction in JavaScript