Page 190 - DCAP408_WEB_PROGRAMMING
P. 190

Web Programming




                    Notes            All right, what  is JavaScript? Designed by  Netscape Communications  and Sun,  it is a
                                     “lightweight programming language that you can use to add dynamic effects to your Web
                                     pages.” HTML has limitations, because it can only describe the way a page’s elements such
                                     as text, forms, hyperlinks and tables look like; it cannot dictate how they behave which is
                                     where JavaScript steps in. “The ability to embed JavaScript scripts in a Web page gives
                                     you, the programmer, much more control over how your Web page behaves.” When you
                                     use it in combination with the browser’s Document Object Model (DOM), JavaScript can
                                     produce intricate, dynamic HTML effects as well as animation and sound.
                                     If your job is in IS security, you must remember that JavaScript has a history of security
                                     problems. Most of these security holes have been caught and fixed, “but new ones are
                                     being discovered all the time.” So, a developer has to “keep up-to-date on the current
                                     status” of patches and bugs.
                                     The book’s lingo is simple. Try  this: “The most important thing to know about  using
                                     functions is how to make them work. Only three conditions need to be met for a function
                                     call to succeed. First, the function must have been previously defined  in the program.
                                     Second, the correct number of parameters must be passed to it. Lastly, the correct object
                                     must be present - you cannot call the string object’s split function without a string object.”
                                     A book to invoke before you launch upon your own project.

                                   6.4 Summary

                                      JavaScript enabled browsers recognizes  and uses the Document  Object Model  (DOM)
                                       which makes them capable of recognizing individual objects in an HTML page after the
                                       page has been rendered in the browser.
                                      Style Sheets are a language used for specifying formatting and layout properties for a document.

                                      When JavaScript Assisted Style Sheets (JSSS) are embedded in an HTML page, the JavaScript
                                       DOM picks up a whole new set of objects which add to the standard DOM objects which
                                       enables web developers to access  every element of a  web page whether this  element
                                       appears on the page when it is rendered in a client browser or not.
                                      Since JavaScript understands the DOM and can extend the DOM with the use of JSS in a web
                                       page JavaScript understands objects such as text box which is an object belonging to the DOM.
                                      All objects have properties that determine the functionality of the object, methods which
                                       allow access to these properties and events to appropriate JavaScript event handlers.

                                      To handle document objects JavaScript enabled browser creates an array in memory per
                                       HTML object thus registering each of the objects.

                                      JavaScript provides access to the  arrays and  their elements.  Using the Methods of the
                                       object, specific object properties can be set too.
                                      Updating of any web page element based on client input to make the web page interactive
                                       can be done by referencing the appropriate element in its associated array, which provides
                                       access to each element of the web page.

                                      JavaScript provides ‘Event Handlers’ which facilitate the  passing of  knowledge to the
                                       JavaScript that an  ‘event’ has occurred.
                                      JavaScript event handlers can be divided into two types interactive and non-interactive.
                                       JavaScript identifies a web page object first and chooses an appropriate event associated
                                       with the object and JavaScript event handlers mapped to  an objects  event connect the
                                       object event and JavaScript code snippets.




          184                               LOVELY PROFESSIONAL UNIVERSITY
   185   186   187   188   189   190   191   192   193   194   195