Javascript Exercises
Javascript Exercises
Exercises
7-1.html
<html>
<body>
<script
type="text/javascript">
<!--
document.write("Hello
World!")
//-->
</script>
</body>
</html>
7-2.html
<html>
<body>
<script
type="text/javascript">
<!--
var
x
=
2
*
2
document.write("x
=
",
x)
//-->
</script>
</body>
</html>
7-3.html
<html>
<HEAD>
<SCRIPT
LANGUAGE="JavaScript">
<!--
Hide
script
from
old
browsers
function
square(number)
{
return
number
*
number
}
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT>
document.write("The
function
returned
",
square(5),
".")
</SCRIPT>
<P>
All
done.
</BODY>
</html>
function AddZero(i) { // call the Time function if (i<10) <body onload="Time()"> {i="0" + i} return i </body> } </html> </script> </head> 1. Enter all code examples as separate files and debug. You will likely make typing mistakes and this will cause the code examples to not work properly. Make sure they work properly before you go on to step 2. 2. Change some aspect of these code examples, either in the html or JavaScript. A change might be the use of a different formula, different output text, or different function call. 3. Put these files in a folder called JavaScript. 4. Create a new index.htm file for your new JavaScript folder. This index.htm file would look like the following: <html> <h1> My JavaScript programs </h1> <h3> ______Name________ </h3> <hr> <a href=7-1.html> 7-1 </a> <br> <a href=7-2.html> 7-2 </a> <br> etc. </html> 5. Upload the JavaScript folder to your CartGIS folder in the Public folder in myfolder. 6. Modify your base index.htm file by adding the following lines: <h3> My JavaScript Examples </h3> <a href=/JavaScript/> JavaScript Examples </a> 7. Replace your base index.htm file in your CartGIS folder on myfolder.