JavaScript Tutorial/Language Basics/Comments — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:24, 26 мая 2010
Hide scripts using comments
<html>
<head>
<title>Hide scripts using comments.</title>
<script language="javascript" type="text/javascript">
<!--
lines of JavaScript code here
...
//-->
</script>
</head>
<body>
Page content here...
</body>
</html>
Multiline comments
/* */ enables comments to span multiple lines.
<html>
<head>
<title>A Simple Page</title>
<script language="javascript">
<!--
/*
Below two alert() methods are used to
fire up two message boxes - note how the
second one fires after the OK button on the
first has been clicked
*/
alert("An alert triggered by JavaScript!");
alert("A second message appears!");
// -->
</script>
</head>
<body>
</body>
</html>
Single line comments
The // comment tag enables comments to be placed between the // and the end of the line.
<html>
<head>
<title>A Simple Page</title>
<script language="javascript">
<!--
// The first alert is below
alert("An alert triggered by JavaScript!");
// Here is the second alert
alert("A second message appears!");
// -->
</script>
</head>
<body>
</body>
</html>