www.freewebsite.0nyx.com
You are here: Home >> JavaScript tutor >> Lesson 1 www.freewebsite.0nyx.com - Free Website
 
Site guide
 HOME
 SITE MAP
 
Free tutorials
 Free Flash tutor
 Free HTML tutor
 Free JavaScript tutor
 Free DHTML tutor
 
Free Online Tools
 Color Picker
 MouseOver buttons
 Menus : Dropdown
 Page effects
 Scrollbar
 
More stuff
 Free sub-domains
 Make money : Banners
 Increase traffic
 Improve your website


Become a member become a member      Member's Log-in

JAVASCRIPT LESSON 1

Open up Notepad. Start by writing or copying this:

<html>
<head>
<title></title>
</head>
<body>

</body>
</html>
Save the file as hello_world.html or whatever name you prefer.



Now insert the script tags.
<html>
<head>
<title></title>

<script type="text/javascript">

</script> 

</head>
<body>

</body>
</html>
Notice that the script tags are after the title tags but between the head tags.

They should not go between the body tags (for now). More on this in chapter 3.



Now insert a empty function.
<html>
<head>
<title></title>

<script type="text/javascript">  
function () {

} 

</script> 

</head>
<body>

</body>
</html>
A function gives instructions or tells what to do.



Now give the function a name. We'll call it Hello for now.
<html>
<head>
<title></title>

<script type="text/javascript"> 
function Hello () {

}

</script> 

</head>
<body>

</body>
</html>


Now we'll insert an alert box that says "Hello there."
<html>
<head>
<title></title>

<script type="text/javascript"> 
function Hello () {
 alert ("Hello there!") 
}

</script> 

</head>
<body>

</body>
</html>
Notice how the function is structured. Pay close attention to the following:

"" - quotation marks
() - parentheses
{} - curly brackets

Don't worry about these now. We'll get into them later.



The function won't work by itself. You need to insert a link that calls the function.
<html>
<head>
<title></title>

<script type="text/javascript"> 
function Hello () {
 alert ("Hello there!") 
}

</script> 

</head>
<body>

<a href="javascript:Hello()"> Hello there </A> 

</body>
</html>
And you're done. Not TRY IT.



VERY IMPORTANT: JavaScript is CASE-SENSITIVE.

function Hello is not the same as function HELLO.

Case-sensitive errors can be very frustrating. Trust me. A capital letter makes a world of difference in javascript.


< < Back     Next > >
Freewebsite: Web design tutorials for the rest of us
Lessons:      Intro 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

 
Praise for freewebsite
   "These tutorials are written in such simple language and they're so much fun. They're simply the best." - Mike

   "Just wanted to drop you a line to say thank you. I created my website within a month after reading your tutorials and now I make thousands with it." - Ken