About JavaScript
Why JavaScript
As mentioned earlier, HTML was not intended to control the appearance of pages in a Web browser. At that time, Web pages were static, that is, they couldn�t change after they were rendered by the browser. However, once the Web grew beyond a small academic and scientific community, people began to recognize that greater interactivity and better visual design would make the Web more useful. As commercial applications of the Web grew, the demand for more interactive and visually appealing Web sites also grew. The biggest challenge in meeting this demand was that HTML and XHTML could only be used to produce static documents. You can think of a static Web page written using HTML or XHTML as being approximately equivalent to a document created in a wordprocessing or desktop publishing program; the only thing you can do with it is view it or print it.Thus, to respond to the demand for greater interactivity, an entirely new Web programming language was needed. Netscape filled this need by developing JavaScript.
When it comes to Web development, the term scripting language refers to any type of language that is capable of programmatically controlling a Web page or returning some sort of response to a Web browser. It�s important to note that although the term scripting language originally referred to simple programming languages, today�s Web-based scripting languages are anything but simple.
The part of a browser that executes scripting language code is called the browser�s scripting engine. (A scripting engine is just one kind of interpreter, with the term interpreter referring generally to any program that executes scripting language code.) When a scripting engine loads a Web page, it interprets any programs written in scripting languages, such as JavaScript. A Web browser that contains a scripting engine is called a scripting host. Internet Explorer and Netscape are examples of scripting hosts that can run JavaScript programs.
What is JavaScript?
- JavaScript was designed to add interactivity to HTML pages
- JavaScript is a client-side scripting language that allows Web page authors to develop interactive Web pages and sites.
- Client-side scripting refers to a scripting language that runs on a local browser (the client) instead of on a Web server, which is a special type of computer used for hosting Web sites.
- A scripting language is a lightweight programming language
- A JavaScript consists of lines of executable computer code
- A JavaScript is usually embedded directly into HTML pages
- JavaScript is an interpreted language (means that scripts execute without preliminary compilation)
- Everyone can use JavaScript without purchasing a license
- Originally designed for use in Navigator Web browsers, JavaScript is now also used in most Web browsers including Internet Explorer.
What can a JavaScript Do?
- JavaScript gives HTML designers a programming tool - HTML authors are normally not programmers, but JavaScript is a scripting language with a very simple syntax! Almost anyone can put small "snippets" of code into their HTML pages
- JavaScript can put dynamic text into an HTML page - A JavaScript statement like this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML page
- JavaScript can react to events - A JavaScript can be set to execute when something happens, like when a page has finished loading or when a user clicks on an HTML element
- JavaScript can read and write HTML elements - A JavaScript can read and change the content of an HTML element
- JavaScript can be used to validate data - A JavaScript can be used to validate form data before it is submitted to a server. This saves the server from extra processing
- JavaScript can be used to detect the visitor's browser - A JavaScript can be used to detect the visitor's browser, and - depending on the browser - load another page specifically designed for that browser
- JavaScript can be used to create cookies - A JavaScript can be used to store and retrieve information on the visitor's computer
