What Is Scripting ?
- Scripting refers to a series of commands that are interpreted and executed sequentially and immediately on occurrence of an event.
- This event is an action generated by a user while interacting with a Web page.
- Examples of events include button clicks, selecting a product from a menu, and so on.
- A scripting language refers to a set of instructions that provides some functionality when the user interacts with a Web page.
- Scripting languages are often embedded in the HTML pages to change the behavior of the Web pages according to the user’s requirements.
There are 2 Types of Scripting Languages
- Client-Side Scripting
- Server-Side Scripting
Refers to a script being executed on the client’s machine by the browser.
Refers to a script being executed on a Web server to generate dynamic HTML pages.
- In real life, an object is a visible entity such as a car or a table having some characteristics and capable of performing certain actions.
- Similarly, in a scripting language, an object has a unique identity, state, and behavior.
- The identity of the object distinguishes it from the other objects of the same type.
- The state of the object refers to its characteristics, whereas the behavior of the object consists of its possible actions.
- The object stores its identity and state in fields (also called variables) and exposes its behavior through functions (actions).
|1.1||Is supported from 3.0 version of the Netscape Navigator and Internet Explorer.|
|1.2||Is supported by the Internet Explorer from version 4.0|
|1.3||Is supported by the Internet Explorer from version 5.0, Netscape Navigator from version 4.0, and Opera from version 5.0.|
|1.4||Is supported by servers of Netscape and Opera 6.|
|1.5||Is supported by the Internet Explorer from version 6.0, Netscape Navigator from version 6.0, and Mozilla Firefox from version 1.0.|
|1.6||Is supported in the latest versions of the Internet Explorer and Netscape Navigator browsers. It is also supported by Mozilla Firefox from version 1.5.|
|1.7||Is supported in the latest versions of the Internet Explorer and Netscape Navigator browsers. It is also supported by Mozilla Firefox from version 2.0.|
- A client-side script might contain instructions for the browser to handle user interactivity.
- These instructions might be to change the look or content of the Web page based on the user inputs.
- Examples include displaying a welcome page with the user name, displaying date and time, validating that the required user details are filled, and so on.
- In client-side scripting, when an HTML is requested, the Web server sends all the required files to the user’s computer.
- The Web browser executes the script and displays the HTML page to the user along with any tangible output of the script.
- Server-side scripting fulfills the goal of providing dynamic content in Web pages.
- Compilation is a process of converting the code into machine-independent code.
- This machine-independent code is known as the bytecode, which is an executable file that the Web server runs to generate the desired output.
Information About <Script> Tag
- The <script> tag defines a script for an HTML page to make them interactive.
- The browser that supports scripts interprets and executes the script specified under the <script> tag when the page loads in the browser.
- You can define multiple <script> tags either in the <head> or in the <body> elements of an HTML page.
- In HTML5, the type attribute specifying the scripting language is no longer required as it is optional
The Code Snippet demonstrates the use of the <script> tag
<!doctype html> <html> <head> <script> document.write(“Welcome to the Digital World”); </script> </head> <body> ..... </body> </html>