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, and its return value is Boolean type. Click to confirm that the return value is ture, and click to cancel the return value is false.
For example:
The code copy is as follows:
<script type="text/javascript">
var mymessage=confirm("Do you like JavaScript?");
if(mymessage==true)
{ document.write("Good, come on!"); }
else
{ document.write("JS is powerful, you need to learn!"); }
</script>
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: A dialog box pops up to ask about information about interaction with the user
For example:
The code copy is as follows:
var myname=prompt("Please enter your name:");
if(myname!=null)
{ alert("Hello"+myname); }
else
{ alert("Hello my friend."); }
3.window.open opens a 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 of the control window
Function: Open a new window
For example:
The code copy is as follows:
<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 closes new window
Syntax: window.close('str'); or <new window>.close();
Parameter description: str is the address of the open window
For example:
The code copy is as follows:
<script type="text/javascript">
var mywin=window.open('http://www.imooc.com'); //Storage the newly-printed window object in the variable mywin
mywin.close();
</script>
5.alert warning
Syntax: alert("str");//Note that it is double quotes
Parameter description: str is the content popped up in the dialog box
For example:
The code copy is as follows:
<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:
The code copy is as follows:
</pre><pre name="code"><script type="text/javascript">
document.write("I love JavaScript!"); //The content is enclosed with "" and the content in "" is output directly.
</script>
The above six points are all the content shared by this article. I hope you like it.