JavaScript?
Javascript 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, javascript
is easy programming language specifically designed to make a web page
elements interactive. An interactive element is one that responds to a user's
input. It's developed by NetScape and is not connected to Java but has similarity with C and C++.
JavaScript is case sensitive.
Like the HTML javascript uses open and close tags. Use the following
syntax to start and end any javascript code. <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 javascript, 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 javascript dominated page
and writes same text on the browser.
<html> <head>
</head> <body>
<script language="javascript">
alert("This is a javascript dominated page");
document.write("This is a javascript 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 javascript dominated page")
Alert is a javascript method that displays provided string value within brackets.
Then we write same message on the browser using this statement:
document.write("This is the javascript dominated page")
Document is an object means this page. Write is a method that instructs the browser to
write the provided string value.
Javascript code can be placed in the head or body section of the html
document. The head section is best suited for all your functions and the body
section is best for immediate execution code like the one above.
Home
Variables & Arrays
|