| |
| Overview |
| |
In this chapter you will learn :
- Introduction to JavaScript.
- More about JavaScript.
- What JavaScript can do.
|
| |
Introduction to JavaScript
Today's web sites are quite interactive. Web browsers allow users to interact with such web sites. HTML in itself is static and allows minimal interaction with users. Truly interactive pages cannot be created using standard HTML 'tags' alone. Embedding JavaScript in an HTML program makes this possible.
JavaScript is an easy-to-use scripting language (web site development environment) that can work with HTML. It has been developed by Netscape. The web pages created by JavaScript can accept input from a user, detect browsers, create cookies, primitive games, create calculator, or show the current date and time. In short, it makes the web site dynamic in nature.
JavaScript is of two types
- Client-side JavaScript, called Navigator JavaScript
- Server-side JavaScript, called Live Wire JavaScript
More About JavaScript
- JavaScript is a compact object-based scripting language. A script is a segment of code that manipulates the browser and its contents.
- JavaScript is a programming language that can be written into HTML documents to increase interactivity with the user.
- JavaScript is created by Netscape and hence best supported with the Netscape suite of Client and Server products.
- JavaScript is easy to implement, as a complier is not needed for execution.
- JavaScript requires an interpreter for execution.
- JavaScript provides the facility of event driven programming.
- JavaScript is the default scripting language that Netscape understands.
- JavaScript is architecture neutral language and is independent of the hardware on which it works. It is a language that is understood by any JavaScript enabled browser.
- Unlike HTML, JavaScript is a case-sensitive language.
Advantages of JavaScript
JavaScript offers several advantages to a web developer. The strength of JavaScript can be easily and quickly used to extend the functionality of HTML pages, already on a web site. Various operations possible through the JavaScript are :
- Allowing the creation of 'Interactive' web pages. These pages can accept input from a user and based on the input received, will return the customized web page to the user.
-
JavaScript also provide the facility for 'Validating' user input. Data is validated before submitting it to the server and hence server is saved from extra processing.
-
JavaScript is an 'Event-driven programming'. JavaScript recognizes when a form 'button' is pressed. This event can have the suitable JavaScript code attached, which will execute when the 'button pressed' event occurs. Various events possible with the JavaScript are: onClick, onDragDrop, onKeyDown, KeyPress, KeyUp, MouseDown, MouseOver, MouseMove, Resize, onLoad, onUnLoad, onChange etc.
-
JavaScript can be used to create 'Cookies'. The script checks if the user has cookies enabled in his browser or not. If the cookies are enabled, then the JavaScript can be used to store and retrieve information on the visitor's computer.
-
Many 'GUI features', such as alerts, prompts, confirm boxes and other GUI elements are handled by client side JavaScript.
-
The 'Navigator object' is used to reveal information about the browser your visitors are using. Certain browsers can't deal with certain things, so the navigator object is typically used to load another page designed for that browser.
-
JavaScript provides 'Syntax', which can be used to add procedural capabilities (such as condition checking, looping and branching) to web page coding.
- With 'JavaScript Clock', you can place a digital clock on your web page.
- Using 'JavaScript Functions', a calculator can be created.
| |
| |
| Summary |
| |
In this chapter you have learnt:
- How JavaScript can enhance a website by adding interactive pages.
- JavaScript is different from HTML.
- Various advantages of JavaScript over HTML.
- Various operations possible through JavaScript.
|
| |
| Review Questions |
| |
Fill in the Blanks
- JavaScript is an --------- scripting language.
- JavaScript is created by ---------.
- Client-side JavaScript is called -------- JavaScript.
Solutions
- object-based
- Netscape
- Navigator
True or False
- JavaScript needs compiler.
- JavaScript is not an architecture neutral language.
- JavaScript is a case-sensitive language.
- The default scripting language of Netscape is VBScript.
Solution
- False
- False
- True
- False
|
| |
| What's Next |
The next chapter will acquaint you with the basic JavaScript concepts. The chapter will further elucidate where to add <SCRIPT>tag in an HTML document.
Hop over to the next chapter to get the close-up of JavaScript concepts.
|
|
|
|