Introduction to JavaScript

What is JavaScript?

Advantages of Using JavaScript (Client-Side)

  • Validate user's input.
  • Perform aggregrate calculations.
  • Easily prompt a user for confirmation, alert, pop-up information.
  • Easy and powerful control of Web browser's behaviors and HTML page component's properties.
  • Conditionalize HTML.
  • Perform other opeations in the client, independent of server information.
  • Control of Dynamic HTML.

Advantages of Using JavaScript (Server-Side)

  • Maintain information through a series of client access.
  • Maintain data shared among several clients or applications.
  • Access databases/files on the server
  • Call external objects, or libraries on the server.
  • Generate HTML output dynamically.

JavaScript on Web Browser

<html>
<head><title>JavaScript in Browser</title></head>
<body>
<script language="JavaScript">
var titleNo=2;
document.write("<h1>Document No"+titleNo+" </h1>\n");
</script>
</body>
</html>

JavaScript on Web Server

Netscape Enterprise Server:

<server>
...
</server>

ASP (Microsoft IIS, PWS):

<%@ LANGUAGE = JScript %>
<% ... %>