About Javascript


Javascript is a script language developed by Netscape Communication Corporation. It isn't a programming language like the Java language. Javascript's statements are embedded in an HTML page (you should know the HTML language before following this course...). When you download a web page by means of a client such as Netscape Navigator or Internet Explorer, the client reads the page from top to bottom, displaying it according to HTML rules. However you can also use Javascript. Javascript scripts are freeware, because you can read HTML pages in order to discover how they are built. I could say that Javascript is a 'cut&pasteware' language...In fact, all you need is inside of the HTML page (a piece of that page): just cut and paste it! Netscape Navigator's versions previous to 2.0 can't interpret Javascript, so if you have those versions, I suggest you a newer version (while I'm writing, the current Netscape's browser version is the 4.0). I think it is worth, because by means of Javascript you can do fantastic things. In addition, the current Javascript version is the 1.2 (in this case you need Netscape Navigator 4.0, because Navigator 3.0 can't interpret Javascript version higher than 1.1). Javascript is an object oriented script language and its statements are quite similar to C language statements. If you know Java or Visual Basic or C++ you can understand me when I talk about 'Object Oriented Programming Language' and about 'Events'. However, if you don't know these languages, don't worry: Javascript is really simple, and I will explain you all these concepts.

Objects

First of all, let me say that there is a client-side Javascript and a server-side Javascript. Server-side Javascript has its own objects. However I won't talk about server-side Javascript, but I will talk about the client-side Javascript. Besides, you could define your own objects. Ok, but now let's talk about these objects...Well, objects are simply 'things' which you can 'handle' by means of an object oriented language such as Javascript. Look at your desktop for example: the Win95 start button is an object; the screen is an object; a window is an object, a Word document is an object and so on...By means of Javascript, you can handle some of these objects, but I will talk about that later.

Events

Events are things that a web page visitor can do. When you visit a web page for example, you could find some links...When you click on a link, that is an event (the 'Click' event). When you press a key, that is another event (the 'KeyPress' event). In other words, the user's (the web page visitor's) actions, are events. Well, it isn't really so, because there are events which aren't due to user's actions, such as the 'error' event. The error event may occurs during the loading of an HTML page or an image for example. In Javascript, there is an 'event handler' for each event. The name of the event handler is the name of the event preceded by 'on'. For example, the event handler for the click event is 'onClick'.

Javascript and Java

Well, now let's see the differences between Javascript and Java:

Javascript

Java

  • Interpreted by client while it reads the HTML page. It can't be executed outside of a web browser
  • Compiled bytecode downloaded from server and executed by client. However it is a multiplatform language and it may be executed inside of all operating systems which have a Java Virtual Machine (also outside of a web browser)
  • Code embedded in HTML page
  • Applet distinct from HTML page
  • Object-based: objects can have their property added dynamically
  • Object-oriented: objects can't have their properties added dynamically. All objects are divided into class
  • Objects references checked dynamically at runtime
  • Objects references checked at compile-time
  • Variable data types not declared
  • Variable data types must be declared

Index           Home  Back       About  Contact us!

Copyright (c) 1998-2006 Wowarea