Script h e a d b o d y global variables

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t;head></head>. </script> </h e a d > <b o d y > ... ... Global variables and functions declared in one block can be accessed from other locations. Eg., the previous Counter example. Try out: Add 10 to the counter (add a add10() function in a new JavaScript block) Global variables and functions are normally created in <head>..</head>. Reasons: (1) The browser loads everything in the <head> tag before it starts executing any JavaScript. That means, if we put global variables and functions in <head>, then they can be used immediately when the page begins to load. (CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong .. .. .. <script type="text/javascript"> .. .. .. </script> .. .. .. .. .. <script type="text/javascript"> .. .. .. </script> .. .. .. </b o d y > </h tm l> ... ... ... ... (2) Easier to lookup. http://www.cs.cityu.edu.hk/~helena 4. Program Structure III - 3 Na...
View Full Document

This note was uploaded on 03/10/2012 for the course CS 1301 taught by Professor Dr.wong during the Winter '08 term at City University of Hong Kong.

Ask a homework question - tutors are online