JavaScript - Dynamic HTML

JavaScript has been created by Netscape to embedd procedural programming into HTML and build dynamic web pages. It is used also to enable scripting in some applications of markup languages (PDF, photoshop, XUL, use JavaScript). The syntax of the language is similar to that of Java or C.
JScript is a compatible version implemented by Microsoft in 1996, for Windows only.
Elements of a web page are accessed as a hierarchy of objects, including those of the Document Object Model (DOM, a standard by the W3C): document, window, form, table, etc... No file output is provided, for security.
The format described here is ECMAScript 1.5, the standard defined by the ECMA group in 1999. More recent version exists, but not supported by all browsers.

Features

- Object oriented, uses elements of the page as objects. Dynamic objects.
- No file management nor input-output functions.
- Control of the browser.
- Events.
- Dynamic variables. Declared as var without type. JScript .NET adds optional static type annotations.
- Dynamic and associative arrays.
- Primitive types (but undeclared) are: boolean, string, number, date, array.
- Build-in Date, Math, RegExp objects.
- A for..in construct allows to scan an array.
- Functions are declared with the function keyword, without return type.
- Operators are those of Java plus strict ones: === and !==, for comparing both values and types.

Syntax

Why use it?

Building dynamic web pages, client-side processing. JavaScript is more and more often used as a part of Ajax, an asynchronous protocol for updating content of web pages with data taken from the server. JavaScript Frameworks are developped to build graphical interfaces for web applications.
It is used also to program XML-based graphical user interfaces.

See also

Websites and tools

Sample code

Displaying a text.

<script language ="JavaScript1.2">
  var demo = "demo";
  function dispstring(str)
  { 
      for(i = 0; i < str.length; i++)
      { 
          document.write(str.substring(i, i+1)); 
      }
  }
           
  dispstring(demo); 
</script> 
Programming languages AspectJ - Basic - C - C++ - C# - Eiffel - Go - Java - JavaScript - JavaFX - Pascal - PHP - Python - Rexx - Ruby - Scala - Scriptol - Tcl - HTML - XML - XAML - XUL - SQL

(c) 2006-2009 Scriptol.com