Page 74 - DCAP202_Fundamentals of Web Programming
P. 74

Unit 6: Introduction to JavaScript




          Self Assessment                                                                       Notes

          Fill in the blanks:
          5.   JavaScript can put ........................... text into an HTML page.
          6.   A JavaScript can be used to validate form data before it is submitted to a ...........................

          6.4 Script (<script>)Tag


          In Javascript, SCRIPT tags can be inserted into three places: in between the two BODY tags, in
          between the two HEAD tags, and as a link to an external file, also in the HEAD section.
          Some advocate putting the SCRIPT tags in the BODY section, right at the end. Like this:

                               Figure 6.1: SCRIPT  Tags in the BODY Section






















          The reason to do it this way is because the web page itself will have loaded before the script is
          read. If it’s in the HEAD section, the script will be parsed before any HTML or CSS elements are
          loaded. If your Javascript references any of the web page’s elements, there may be a slight delay
          in the fancy effects you want to apply, or it may just not work at all.

          For the most part, though, we’ll place our script tags in the HEAD section of the HTML. Like this:
                               Figure  6.2: Script  Tags in  the HEAD  Section



























                                           LOVELY PROFESSIONAL UNIVERSITY                                   67
   69   70   71   72   73   74   75   76   77   78   79