Scripts - HTML

HTML is a static method of deploying content—the content is sent out to a client browser where it is rendered and read, but it typically doesn’t change once it is delivered. However, there is a need in HTML documents for such things as decision-making ability, form validation, and, in the case of Dynamic HTML (DHTML), dynamic object attribute changes. In those cases (and more), client-side scripting can be used.

Client-side scripting languages, such as JavaScript, have their code passed to the client browser inside the HTML document. It is the client’s responsibility to interpret the code and act accordingly. Most client-side scripts are contained in the <head> section of the HTML document, within <script> tags, similar to the following example:

In most cases, the document needs to include events to run the script(s). These events can be embedded in elements (via onmouseover or similar attributes), tied to links, called via form elements, or run upon the document being loaded or unloaded (via onload and onunload attributes in the <body> tag).

Note: There are methods to run scripts automatically, that is, without a corresponding event. However, such methods are typically thought of as bad form—it is much better practice to always tie a script’s execution to an event.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status

HTML Topics