Lesson 4: your first script
In this lesson we will get down and dirty and experiment a little with our first working script! We will introduce some actual working code to demonstrate one thing that you will be able to do with javascript. We will be intoducing a couple of built in functions and demonstate the use of variables and structure. Okay, lets look at some code:
var x = "hello ";
var y = "world!";
var z = x + y;
document.write(z);
Code explained:
On the first line we have declared variable x and assigned the string: "hello " to it. On the second line we declared variable y and assigned "world" to it. In the third line we introduce var z and assigned it to the value: x + y. Since x and y are string variables, they will be concatenated. In the last line we introduce the built in write() function and pass the var z to it. When the code is ran it will produce a page that says: hello world!
You Try It:
- Open your JStemplate.txt file.
- Put the above four lines of code in the head section of your template.
- Save it under its new name, alertz.html with the .html extension and close the file.
- Go to the folder you saved alertz.html to and open it.
If it opened a blank html page with an alert box saying "hello world!" then it worked! Congratulations you have completed your first successfull script!
Javascript Discussion
- - Google Chrome / Mozilla?
- - Delete text after focus c
- - Statistics
- - Tabs using javascript
- - Select all values in te
Javascript Source Code
- - E-mail Validation
- - Required Fields
- - Alert User Depending On Browser
- - All Details About Browser
- - More Browser Detection





