Java Script?
Java script is language developed strictly for the web sites
to create interactive web page that can handle calculations, controls such as
displaying certain information when certain values provided, validate forms, and
more without whole lot of programming effort. In short description, java
script is easy programming language specifically designed to make web page
elements interactive. An interactive element is one that responds to a user's
input.
Like the HTML java script uses open and close tags. Use the following
syntax to start and end any java script codes. <script
language="javascript"> put your java script statement
here </script>
<script> - Indicates the document is script language.
<language> - Defines the script language, (eg: javascript, vbscript, etc).
In this case, language is defined as javascript.
</script> - Closes the script tag.
// - This is a comment line for java script, which means the computer will not
interpret this line as a code. The following is simple java script program
displaying a dialog box with the text This is java script dominated page
and writes same text on the browser.
<html> <head>
</head> <body>
<script language="javascript">
alert("This is a java script dominated page");
document.write("This is a java script dominated page");
</script>
<body>
<html>
How it works
We started this code with the start and close tags: Start
<script language="javascript">
Close</script>
Then we display a dialog box with this statement: alert("This is a java
script dominated page")
Alert is a method that displays the string within the brackets.
Then we write same message on the browser using this statement:
document.write("This is the java script dominated page")
Document is an object means this page. Write is a method writes
the string in the brackets to the browser.
Java script code can be placed in the head or body section of the html
document. The head section is best place for all your functions and the body
section is best for immediate execution codes like the one above. The code in
the head section does not execute unless it's called from the body while the one in
the body executes when the page is loaded.
Table Of Content
Variables & Arrays
|