Thursday, 7 December 2017

Dynamic Hosting JavaScript Events

To understand which browser actions correspond to JavaScript events and which do not, it is important to distinguish those actions that actually cause some change in the Web page being displayed.
JavaScript events occur at three levels-at the level of the entire Web document, at the level of an individual <FORM> within the document, and at the level of an element of a <FORM> within that document.

At the same time, any particular element at any of these three levels may result in more than one event.
The FORM tag is used to begin the definition of an HTML form. It includes attributes from the METHOD to be used in submitting the form, the ACTION to be taken, and may also include a single type of event handler attribute, the onSubmit attribute. The syntax for a FORM tag is the following:

<FORM NAME="formname" ... onSubmit="submithandler()">
Every JavaScript function has a built-in property called arguments. The arguments property is an array containing all the arguments passed to the function, indexed beginning with 0.
The arguments property also has a length property, which is the number of arguments passed to the function.

Before JavaScript, the process of creating and validating information that a user entered via a form depended heavily on sending and receiving information from a server-side CGI script. A CGI was possibly used for creating the actual form, validating the information and sending a response back to the user confirming that the information had been sent successfully.

Using JavaScript, you can place much of the work on the client-side, which can reduce dramatically the connection times between the client and the server. In terms of validating form information, you do this by allowing the script to inspect the contents of each field that the user has entered and present an alert to the user if the information does not meet some specific requirements-like too many characters or if the field is empty.

 The onSubmit handler is invoked when the form's contents are about to be submitted. This is a top level action that applies to the entire form. It is also possible to specify an onClick action on the Submit button in a form, "Button Click Events." The natural use of an onSubmit handler is to validate the contents of a form. The submission proceeds if the contents are valid, and is canceled if they are not.

From the user's standpoint the number of such actions is actually quite limited. In fact, there are really only two types of top level actions: the user can navigate, or the user can interact with an element of an HTML form.

These events, loading and unloading a page, are the two document level events that can be handled by JavaScript. This means that it is possible to write JavaScript code, contained within the HTML definition of a page, that will be executed whenever that page is loaded.
You can also have code that is executed whenever that page is unloaded.

Anyone who has used the World Wide Web realizes that selecting a hypertext link may not successfully take you to another. The machine to which that link points may be down, or simply inaccessible. The link may even be dead, meaning that it does not point to a valid destination.

Selecting a dead link often unloads the current page, but doesn't load a new page. Most browsers display a blank page or post an error message. You may or may not be left on the current page, depending on the type of error and the browser being used.

JavaScript uses a text manipulation model which will be familiar to anyone who has ever used a windowing system.

Yes you are absolutely correct.It also defines four events that are associated with text fields and textareas, but not passwords fields.These arer - change, select, focus, and blur.