Java Script

Java Script


Previous (XML DTD)

  • Java Scipt is written in HTML page.
  • Java Script is a programming language. It is used to validate the client data.
  • If the the client (or user) data is correct, then the data is submitted to server for further processing.
  • Java Script is generally run at client side to save processing time of server.
  • Java Script is easy programming language.
  • Java Script is based on object oriented programming concepts.
  • Java Script is written between <script> ... </script> tags.

Three ways of writting Java Script

Method 1: Java Script in Body Tag of HTML

Example 1


Explanation of the program

  • Java Script is written in body tag of HTML within <script> tag.
  • In this program, predfined Java Script object document is used.
  • Predefined object document calls predefined method write() to display a message on the web page.
  • Method write("Dear Janhvi") displays the message "Dear Janhvi" on the web page.

Method 2: Java Script in Head Tag of HTML

Example 2


Explanation of the program

  • Java Script is written in Head tag of HTML within <script> tag.
  • A function named dispName is defined in the script.
  • Within the function dispName () , object document is used to display the message Dear Janhvi .
  • A button is defined within body tag of HTML.
  • When button is clicked, java scipt function dispName() is called and it displays the message Dear Janhvi on the web page.