JavaScript?
Javascript is a language developed exclusively for websites to create interactive web pages that can handle the calculations, controls how to display certain information when the values of certain data, validate forms, and more without much programming effort. In brief description, is easy Javascript programming specifically designed to make an interactive website elements. An interactive element is one that responds to input from a user. It is developed by Netscape and not connected to Java, but has similarity to C and C + +. JavaScript is case sensitive.
Like HTML uses Javascript to 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.