6FuncObjI - JavaScript Global Functions and Objects I...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 6. Functions and Objects I - 1 http://www.cs.cityu.edu.hk/~helena JavaScript JavaScript Global Functions and Objects Global Functions and Objects I I Introduction to JavaScript Objects and HTML Element Objects Global Functions: isFinite, isNaN, escape/unescape, eval Creation of Objects: the new operator and constructor functions Commonly used objects: Window: Math and Random Number Generation Date ------------------------------------------------------------------------------ In next powerpoint, we will have: Array String Document and Adding Cookies Forms: Style, Cascading Style Sheets (CSS) and Dynamic HTML (DHTML)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 6. Functions and Objects I - 2 http://www.cs.cityu.edu.hk/~helena What are Objects Objects : An object is a collection of named values called properties . Each property may contain any type of data, functions, and even other objects. Example: The document object may contain a form object named F1: do c um e nt.F1 The form may contain 2 input box objects with names equal to n1 and n2: do c um e nt.F1.n1   and  do c um e nt.F1.n2 The input boxes may contain several properties like: value, size, readOnly: document.F1.n1.value The properties can be examined as follows: [Refer to Lec03_Slide12_V4_MarksToGrade.htm]
Background image of page 2
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 6. Functions and Objects I - 3 http://www.cs.cityu.edu.hk/~helena What are Objects Exercise: [Refer to Lec02_Slide13_V4_MarksToGrade.htm] What will be shown by running the statements below? javascript:alert(document.F1.CGrade.readOnly) javascript:alert(document.F1.CGrade) javascript:alert(document.F1) javascript:alert(document) javascript:alert(document.write) javascript:alert(convertAll)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
(CS1301) Introduction to Computer Programming City Univ of HK / Dept of CS / Helena Wong 6. Functions and Objects I - 4 http://www.cs.cityu.edu.hk/~helena HTML Elements as JavaScript Objects Handling HTML Elements as JavaScript Objects Contents in a webpage are automatically represented as "objects contained in the document object" (ie. a property of the document object). 2 simple methods to refer to these contents: (1) Each element object in the webpage body, that contains an ID, can be referred using document.getElementById( id ). If it contains a pair of starting and ending tags, the HTML text in-between the tags can be referred as the innerHTML property: document.getElementById( id ).innerHTML (2) For forms and form elements, there is one more method to refer to them. Any form object is an individual property of the document, can be referred by its name.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 14

6FuncObjI - JavaScript Global Functions and Objects I...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online