JavaScript is a new scripting language for Web- pages. Scripts written
with JavaScript can be embedded into your HTML- pages. With JavaScript
you have very many possibilities for enhancing your HTML- page with
interesting elements. For example you are able to respond to user-
initiated events quite easily. Some effects that are now possible with
JavaScript were some time ago only possible with CGI. So you can create
really sophisitcated pages with the help of JavaScript. You can see many
examples for JavaScript scripts on the Internet. Best you have a look at
some JavaScript enhanced pages. You can find many links at
Gamelan (in the JavaScript section).
You will find the documentation provided by Netscape at
http://home.netscape.com.
Although the names are almost the same Java is not the same as
JavaScript! These are two different techniques for Internet programming.
Java is a programming language. JavaScript is a scripting language
(as the name implies). The difference is that you can create real
programs with Java. But often you just want to make a nice effect
without having to bother about real programming. So JavaScript is meant
to be easy to understand and easy to use. JavaScript authors should not
have to care too much about programming. You could say that JavaSript is
rather an extension to HTML than a separate computer language. Of course
this is not the 'official' definition but I think this makes it easier
to understand the difference between Java and JavaScript. You can find
further information about both Java and JavaScript at
Gamelan.
For further information about this topic please read the introduction
provided by Netscape.
The first browser to support JavaScript was the Netscape Navigator 2.0.
Of course the higher versions do have JavaScript as well. You might know
that Java does not run on all Netscape Navigator 2.0 (or higher) versions.
But this is not true for JavaScript - although there are some problems
with the different versions. The Mac- version for example seems to have
many bugs. In the near future there are going to be some other browsers
which support JavaScript. The Microsoft Internet Explorer 3.0 is going
to support JavaScript. JavaScript- enabled browsers are going to be
wide spread soon - so it is worth learning this new technique now. You might
realize that is really easy to write JavaScript scripts. All you have to
know is some basic techniques and some work- arounds for problems you
might encounter.
If you are using a JavaScript - enabled browser at the moment then you
will have the possibility
to see this script working. If your browser doesn't support JavaScript then this
output might be some kind of strange...
This is This is JavaScript!
I must admit that this script is not very useful. You could write that in HTML
much faster and shorter. But what I wanted to show is how you have to use the
What is the difference between Java and JavaScript?
How can JavaScript scripts be run?
Of course you need a basic understanding of HTML before reading this tutorial.
You can find many really good online ressources about HTML. Best you
make an online search about 'html' at Yahoo if
you want to get informed about HTML. (These online- documents are often
more up-to-date than books. The Internet is moving quite fast these days...)
Now I want to show some small scripts so you can learn how they are
implemented into HTML- documents and to show which possibilities you have with
the new scripting language. I will begin with a very small script which will
only print a text into an HTML- document.
<html>
<head>
My first JavaScript!
</head>
<body>
<br>
This is a normal HTML document.
<br>
<script language="JavaScript">
document.write("This is JavaScript!")
</script>
<br>
Back in HTML again.
</body>
</html>
Back in HTML again.