|I have visited many publications on
the Internet and have used some of them to choose and prepare the lessons
for my students. Thank you to all authors, who has published free their
work. My work is FREE for all on the net, too. I hope this Tutorial will
help to everyone who wants to make attractive web pages! Enjoy! The
main lessons are:
is Java Script?
It is a scripting language developed by Netscape to add
interactivity and power to web documents. Examples
of Java Script include live clocks, rollover effects, scrollers,
in that it is relatively easy to master,
even for people who have absolutely no programming
With html, you are restricted to creatingstatic, non
interactive webpages. This, in today's internet standards, is unacceptable.
Getting Started: Setting Up your
the <html> tags of your page. The beginning of your code begins
with <script> and ends with </script>
The tags <!-- and //--> are comment tags
and should always be included to help hide your code against older browsers.
The only "functional part" of this script is the document.write("....")part.
write a line of text.
"document" is the object
in the above example.
"write" is the method of
them have both methods and properties.
bgColor (changes background color)
lastModified (gives date of document's last change)
document.write (gives date of document's last change)
referrer (gives URL of the page that linked here)
fgColor (changes foreground color)
write (writes something)
writeln (writes in new line)
They achieve more complex task and are not executed
until you call upon them.
The basic syntax of a function is:
It will be not enough to put this in the <script></<script>
tags so to see the text on the screen. The function must be implement by
This function doesn't use parameters.
In the next example they are used:
enter your age")
The above function doesn't return a value. It only
take a value and use it to
show the result on the screen.
There are many functions which can return a value for
Lets see the example:
enter the length of the rectangle: ")
enter the width of the rectangle: ")
area is "+area(a,b))
Now we would like to implement for you an example, which
only will teach and show you the possibilities of some functions:
The code is written here:
is a question and the continuation is depended of your
answer! So, are you sure you are OK?")
This answer is shown because you have clicked the button OK!")
bad! This answer is shown because you haven't clicked
the button OK!")
alert("This message is shown with a method ALERT of
the object WINDOW!
You can use it many times in your script!")
var y=window.prompt("Now we are using a method PROMPT
of the object
WINDOW! Your answer will be taken as a value of
the parameter Y! So, please, enter your name instead
of the text undefined!")
result of PROMPT is: "+y)
document.write("This is shown with a method WRITE
of the object DOCUMENT!
It is included in the body of the function!")
are using a method ALERT of the object WINDOW!
This part is not included in a function! Let us start the
execution of the function MAIN_EXAMPLE!")
patient! Just now started the text, which isn't included in
the function! We are using again the method WRITE of the