javascript
TRANSCRIPT
Javascript
* JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari.
* JavaScript was designed to add interactivity to HTML pages * A scripting language is a lightweight programming language
* JavaScript is usually embedded directly into HTML pages
* JavaScript is an interpreted language (means that scripts execute without preliminary compilation)
Uses
* JavaScript gives HTML designers a programming tool.
* JavaScript can put dynamic text into an HTML page.
* JavaScript can react to events.
* JavaScript can read and write HTML elements.
* JavaScript can be used to validate data.
* JavaScript can be used to detect the visitor's browser.
* JavaScript can be used to create cookies.
Javascript Statements
* Javascript is a sequence of statements to be executed by the browser.
* A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do.
* This JavaScript statement tells the browser to write "Hello Dolly" to the web page:
document.write("Hello Dolly");
HTML tags in javascript
The example below shows how to add HTML tags to the JavaScript:
<html><body><script type="text/javascript">document.write("<h1>Hello World!</h1>");</script></body></html>
The document.write command is a standard JavaScript command for writing output to a page.
Javascript Comments
Comments can be added to explain the JavaScript, or to make the code more readable.
Example for comments:
<script type="text/javascript">// Write a headingdocument.write("<h1>This is a heading</h1>");// Write two paragraphs:document.write("<p>This is a paragraph.</p>");document.write("<p>This is another paragraph.</p>");</script>
Advantages
* Advantages include Cross-browser support, validating data on the client, and being able to create more sophisticated user interfaces.
* JavaScript is an excellent solution to implement when validating input forms on the client side.
* This means that if a user forgets to enter his name in a form for instance a JavaScript validation function can popup a message to let him know about the omission.
* JavaScript effects are also much faster to download than some other front-end technologies like Flash and Java applets.