Download presentation
Presentation is loading. Please wait.
Published byGeorgina Arnold Modified over 8 years ago
1
Chapter 9
2
An event-driven, object-based programming language that provides various types of functionality to pages. Object based: it is a language that uses built-in objects that belong to the browser.
3
ObjectDescription ArrayReturns an ordered set of values BooleanConverts objects to Boolean values DateAccesses the system time and date DocumentRepresents the content of a browser's window FunctionAccesses information about specific functions HistoryKeeps track of Web pages visited locationSwitches to a new Web page MathPerforms calculations StringRepresents a set of characters WindowRepresents a browser window
4
attributes that describe an object's characteristics truck.style="pickup“ style=property, pickup = value
5
actions that an object can perform. truck.load() truck = object, load=method, () = arguement
6
value given to a method truck.load("firewood") firewood = describes material loaded into truck
7
Function: code that is written to perform certain tasks repeatedly Placed in the section of the HTML code User defined functions use generic tags to display dynamic information Container: tag that identifies a section of HTML code using the id attribute. Ex:
8
Date() object access the current system date and time Can use 3 other methods to build a string for a a current date: getDate(), getMonth(), getFullYear() Example: var sysDate=new Date() ; var sysDate=new Date(“February 12, 2014”) new is a required keyword 2 nd example specifies a date for the sysDate variable
9
To use the date and time, the variable must be converted to a string toLocaleString() method var variableName=dateString.toLocalString() Example: Var curDate=sysDate.toLocaleString() curDate contains the date and time stored as Day of the Week Month Date Year HH:MM:SS
10
Returns the positions of the first occurrence of a specified value in a string var position=strngValue.indexOf(“x”) Example: curDate=“February 12, 2014” dateLocate=curDate.indexOf(“,”) Returns the position of the comma found in the string value of curDate: 11
11
Uses 2 parameters (x,y) where x is the starting point of the string and y is the location of the last character needed. birthDay.substring(17,20) var variableName=string.substring(x,y) Example: weekDay=dayofweek.substring(0,dateLocate) The variable weekDay containsf the substring result giving the current day of the week.
12
Similar to substring() but differs in how it uses parameter values. Example: var dayofweek=today.toLocaleString() Converts date into string yearLocate=dayofweek.indexOf(“2014”) Year=dayofweek.substr(yearLocate,4) The variable year contains the 4 digit year
13
Can be used to store a future date. var variableName = new Date(“September 26, 2043”)
14
Use the getTime() method of the Date() object Returns the number of milliseconds that have elapsed since Jan. 1, 1970. Must subtract the values to find the milliseconds. var variable = time1.getTime() – time2.getTime()
15
Part of the Math() object Used to round to the nearest Integer To convert milliseconds to days, divide the number of milliseconds stored in the variable by the product of: 1000*60*60*24 var daysToExpo=Math.ceil(daysToGo/(1000*60*60*24))
16
Allows dynamic content to be placed in the contained associated with the unique tag id. Not recognized by Firefox! Use the concatenate (+) sign to link elements tagId.innerHTML=“text string”+variable+”text string”
17
A method of the document object Form: document.getElementsByTagName(‘html’) Example: styleObject= document.getElementsByTagName(‘html’)[0].style [0] represents which value you want returned, in an array format.
18
Only works in IE! Properties available: FaceColor, ArrowColor, HighlilghtColor, 3DlightColor, DarkshadowColor, TrackColor, and ShadowColor Ex: styleObject.scrollbarFaceColor=“#ffde5b”
19
Used with dropdown boxes User selects an item in the list and the selectedIndex property returns the value of the item. Items are “numbered” starting with 0. Form: var Name=formName.SelectListName.selectedIndex
20
Used to tell the browser where the new pages are located (linked in dropdown). Form: object=window.location or window.location = URL Object = variable or other object that can display the URL URL = the address of the page to display
21
lastModified Property displays the dte in the form of mm/dd/yyyy hh:mm:ss Form: document.lastModified lastModified = property of the document object Ex: var lastModified = document.lastModified Could use: var lastModified =lastModified.substring(0,10) to only get date, not time.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.