Page 140 - DCAP408_WEB_PROGRAMMING
P. 140

Web Programming




                    Notes          5.1.2 Disadvantages of JavaScript

                                      If you lack experience in programming, JavaScript will look daunting to you. Often, it is
                                       not clear how the code works when you examine the HTML source. Long, complicated
                                       Java scripts can add quite a bit of download time to your HTML page.
                                      Although  JavaScript  is  supported on  the  two  major  web  browsers,  there  are  a  few
                                       differences that may cause problems. Many of the graphic HTML creation tools do not
                                       handle JavaScript very well.

                                      Because the code executes on the users’ computer, in some cases it can be exploited for
                                       malicious purposes. This is one reason some people choose to disable JavaScript.




                                      Task   “JavaScript validates data”. Is this a advantage or disadvantage? Analyze

                                   5.1.3 Creating Our First Program in JavaScript

                                   Save the Example 4.1 as MyExample.html and run it in same manner as HTML.
                                   <html>
                                   <body>
                                   <script  type=”text/javascript”>
                                   document.write(“this  is  my  first  program!”);
                                   </script>
                                   </body>
                                   </html>
                                   Output
                                   this  is  my  first  program!

                                   Self Assessment

                                   Fill in the blanks:
                                   1.  JavaScript is primarily a scripting language for use within ………………… pages.
                                   2.  A JavaScript can be used to validate form data before it is submitted to a …………………

                                   3.  Many of the graphic HTML creation tools do not handle ………………… very well.

                                   5.2 JavaScript Data Types

                                   A program can do many things, including calculations, sorting names, preparing phone lists,
                                   displaying images, validating forms, ad infinitum. But in order to do anything, the program
                                   works with the data that is given to it.
                                   Data types specify what kind  of data,  such as numbers and  characters, can  be stored  and
                                   manipulated within a program. JavaScript supports a  number of fundamental  data  types.
                                   These types can be broken down into two categories, primitive data types and composite data
                                   types.






          134                               LOVELY PROFESSIONAL UNIVERSITY
   135   136   137   138   139   140   141   142   143   144   145