2. Copy the following code and save it in
a text editor as hello.html
<html>
<head> <title></title>
</head>
<body>
</body>
</html>
3. Add script tags within head section
The scripts tags tell the <html>
<head>
browser that there is <title></title>
scripting contained
<script
between (in this case
type="text/javascript">
“javaScript”).
</script>
</head>
<body>
</body>
</html>
5. Let’s make a function
• A function executes a <html>
series of instructions. <head> <title></title>
• We will start with an <script
empty shell type="text/javascript">
function () { } </script>
</head> <body>
</body> </html>
6. Function name
We will name our <html> <head>
function Helloworld. <title></title> <script
We will add an alert box type="text/javascript">
that say’s “Hello function HelloWorld() {
World!” alert ("Hello World!"); }
</script> </head>
<body> </body>
</html>
7. Function Structure
• The word function declares that there is a
function.
• The function name is HelloWorld.
• Parentheses () (has use we will get to later in
the course)
• {} curly brackets contain the set of instructions
8. Execute Function
Now that we have <html> <head>
covered the function <title></title> <script
head tags, let’s make it type="text/javascript">
execute when we click function HelloWorld() {
on a link. Here is a alert ("Hello World!"); }
generic link that point </script> </head>
nowhere: <body> <a
href="">Hello</a>
</body> </html>
9. Execute Function
This will make it point <html> <head>
to our function <title></title> <script
type="text/javascript">
function HelloWorld() {
alert ("Hello World!"); }
</script> </head>
<body> <a
href="javascript:HelloW
orld()">Hello</a>
</body> </html>
11. Your first JavaScript
Congratulations, you just made your first
javaScript!
There are two things I would like you to
remember:
1. JavaScript and Java are not the same thing.
2. JavaScript is case-sensitive!