Page 17 - LoudOffice_Guide-to-HTML_Part-II_Advanced.PDF
P. 17

Another attribute of the SCRIPT tag, s r c , can be used to include an external file containing
               JavaScript code rather than code embedded into the HTML:
                   < s c r i p t  l a n g u a g e = " J a v a S c r i p t "  s r c = " c o r e f u n c t i o n s . j s " > < / s c r i p t >
               The external file is simply a text file containing JavaScript code, and whose filename ends
               with the extension ".js". Note that although some version 3 browsers support the SRC
               attribute, it only functions reliably across platforms in version 4+ browsers.

               Scripts can be placed inside comment fields to ensure that your JavaScript code is not
               displayed by old browsers that do not recognize JavaScript. The markup to begin a
               comment field is:

                                                      < ! - -  / /  H i d e
                                                            . . .
                                                     / /  U n h i d e  - - >
               Note that the double back-slash is special for JavaScript. This practice is optional, but
               considered good form when your page is likely to be visited by older browsers. Certainly, as
               older browsers fade away, or considered irrelevant in an intranet environment, this practice
               may be increasingly unnecessary.




               Naming Conventions
               There are some rules and conventions you should follow when naming variables and
               functions.  You may use any combination of letters, numbers, and underscores (_).         You
               cannot begin with a number, and anything you name is case sensitive.  Below are examples
               of legal and illegal names:



                                        LEGAL                              ILLEGAL
                           m y V a r i a b l e                 * m y _ v a r i a b l e
                           m y _ v a r i a b l e               2 m y v a r i a b l e
                           _ m y _ v a r i a b l e             - m y V a r i a b l e
                           m y V a r i a b l e _ 2             _ m y  v a r i a b l e



               Reserved Words
               There are a number of words you may not use within your script.  The following terms are
               reserved by JavaScript and may not be used by you in your scripts:


                           abstract       else              int             switch
                           boolean        extends           interface       synchronized
                           break          false             long            this
                           byte           final             native          throw
                           case           finally           new             throws
                           catch          float             null            transient
                           char           for               package         true
                           class          function          private         try
                           const          goto              protected       typeof


               LoudOffice.com Guide to HTML – Part II                                               Page 17
   12   13   14   15   16   17   18   19   20   21   22