Page 288 - Web Applications (803) Class 11
P. 288

6.   Close the Settings window. JavaScript is now enabled in Microsoft Edge.

              How JavaScript Works on a Webpage?
              JavaScript is a text-based programming language that can be used on both the client and server sides to make web
              pages interactive.

              The steps below demonstrate how JavaScript interacts with the web page:
              1.  A request is sent to the server when the user types an address or URL into the browser.
              2.  The server accepts the browser’s request and sends the page back to it.
              3.  The page is rendered for HTML tags and the contents are displayed by the browser.
              4.  If a page contains JavaScript code that is enclosed by tags, the code is handled by the JavaScript interpreter.
              5.  This code can handle user-initiated events such as clicking a button, rolling the mouse, or submitting a form,
                  among others.
              6.  It makes the web page interactive by detecting and responding to what is happening on the page.
              7.  It has the ability to modify the appearance of a web page or its contents dynamically.
              8,  It has the ability to read and authenticate cookies.

                                                  How JavaScript Works on a WebPage

                                                                              Web Browser

                                                          HTML Parser
                                               Load
                                                                        Parse HTML
                                                  WebPage

                                                                                 DOM

                                                                       Update
                                                Load
                                                           CSS Parser
                                                           CSS Parser
                                                                                    Run Code to modify




                                                      Load


                                                                            JavaScript Engine



                 4.7 BASIC STRUCTURE OF A JAVASCRIPT PROGRAM

              JavaScript cannot run on its own because it is a scripting language, and hence, needs to be embedded within an HTML
              code. The basic structure of a JavaScript program is as follows:

                 <HTML>
                 <HEAD><TITLE></TITLE></HEAD>
                 <BODY >
                 <SCRIPT TYPE="text/javascript">
                 ...
                 Write JavaScript code here
                 ...
                 ...
                286     Touchpad Web Applications-XI
   283   284   285   286   287   288   289   290   291   292   293