📄 js_statements.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript Statements</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>JavaScript Statements</h1>
<a href="js_whereto.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="js_comments.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />
<p class="intro">JavaScript is a sequence of statements to be executed by the
browser.</p>
<hr />
<h2>JavaScript Statements</h2>
<p>A JavaScript statements is a command to the browser. The purpose of the
command is to tell the browser what to do.</p>
<p>This JavaScript statement tells the browser to write "Hello Dolly" to the web
page:</p>
<table width="100%" border="1" class="ex" cellspacing="0" id="table1">
<tr><td>
<pre>document.write("Hello Dolly");</pre>
</td></tr>
</table>
<p>It is normal to add a semicolon at the end of each executable statement. Most
people think this is a good programming practice, and most often you will see
this in JavaScript examples on the web.</p>
<p>The semicolon is
optional (according to the JavaScript standard), and the browser is supposed to
interpret the end of the line as the end of the statement. Because of this you
will often see examples without the semicolon at the end.</p>
<p><b>Note:</b> Using semicolons makes it possible to write multiple statements
on one line. </p>
<hr />
<h2>JavaScript Code</h2>
<p>JavaScript code (or just JavaScript) is a sequence of JavaScript statements.</p>
<p>Each statement is executed by the browser in the sequence they are written.</p>
<p>This example will write a header and two paragraphs to a web page:</p>
<table width="100%" border="1" class="ex" cellspacing="0" id="table3">
<tr><td>
<pre><script type="text/javascript">
document.write("<h1>This is a header</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is another paragraph</p>");
</script></pre>
</td></tr>
</table>
<p><a target="_blank" href="tryit.asp@filename=tryjs_statements">Try it yourself.</a></p>
<hr />
<h2>JavaScript Blocks</h2>
<p>JavaScript statements can be grouped together in blocks.</p>
<p>Blocks start with a left curly bracket {, and ends with a right curly bracket
}.</p>
<p>The purpose of a block is to make the sequence of statements execute together. </p>
<p>This example will write a header and two paragraphs to a web page:</p>
<table width="100%" border="1" class="ex" cellspacing="0" id="table2">
<tr><td>
<pre><script type="text/javascript">
{
document.write("<h1>This is a header</h1>");
document.write("<p>This is a paragraph</p>");
document.write("<p>This is another paragraph</p>");
}
</script></pre>
</td></tr>
</table>
<p><a target="_blank" href="tryit.asp@filename=tryjs_blocks">Try it yourself.</a></p>
<p>The example above is not very useful. It just demonstrates the use of a
block. Normally a block is used to group statements together in a function or in
a condition (where a group of statements should be executed if a condition is
met).</p>
<p>You will learn more about functions and conditions in later chapters.</p>
<hr />
<a href="js_whereto.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="js_comments.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -