JavaScript Object Reference (1)
The anchor Object
See the anchors property of the document object.
The button Object
The button object reflects a push button from an HTML form in JavaScript.
Properties
- name
- A string value containing the name of the button element.
- value
- A string value containing the value of the button element.
Methods
- click()
- Emulates the action of clicking on the button.
Event Handlers
- onClick
- Specifies JavaScript code to execute when the button is clicked.
The checkbox Object
The checkbox object makes available in JavaScript a checkbox from an HTML form.
Properties
- checked
- A boolean value indicating if the checkbox element is checked.
- defaultChecked
- A boolean value indicating if the checkbox element was checked by default (i.e. reflects the CHECKED attribute).
- name
- A string value containing the name of the checkbox element.
- value
- A string value containing the value of the checkbox element.
Methods
- click()
- Emulates the action of clicking on the checkbox.
Event Handlers
- onClick
- Specifies JavaScript code to execute when the checkbox is clicked.
The Date Object
The Date object provides mechanisms for working with dates and times in JavaScript. Instances of the object can be created with the syntax
newObjectName = new Date(dateInfo)
Where dateInfo is an optional specification of a particular date and can be one of the following:
"month day, year hours:minutes:seconds"
year, month, day
year, month, day, hours, minutes, seconds
where the latter two options represent integer values.
If no dateInfo is specified, the new object will represent the current date and time.
Methods
- getDate()
- Returns the day of the month for the current Date object as an integer from 1 to 31.
- getDay()
- Returns the day of the week for the current Date object as an integer from 0 to 6 (where 0 is Sunday, 1 is Monday, etc.).
- getHours()
- Returns the hour from the time in the current Date object as an integer from 0 to 23.
- getMinutes()
- Returns the minutes from the time in the current Date object as an integer from 0 to 59.
- getMonth()
- Returns the month for the current Date object as an integer from 0 to 11 (where 0 is January, 1 is February, etc.).
- getSeconds()
- Returns the seconds from the time in the current Date object as an integer from 0 to 59.
- getTime()
- Returns the value of the current Date object as an integer representing the number of milliseconds since 1 January 1970 at 00:00:00.
- getTimezoneOffset()
- Returns the difference between the local time and GMT as an integer representing the number of minutes.
- getYear()
- Returns the year for the current Date object as an integer representing the year less 1900.
- parse(dateString)
- Returns the number of milliseconds between January 1, 1970 at 00:00:00 and the date specified in dateString. dateString should take one of these formats:
Day, DD Mon YYYY HH:MM:SS TZN
Mon DD, YYYY
- setDate(dateValue)
- Sets the day of the month for the current Date object. dateValue is an integer from 1 to 31.
- setHours(hoursValue)
- Sets the hours of the time for the current Date object. hoursValue is an integer from 0 to 23.
- setMinutes(minutesValue)
- Sets the minutes of the time for the current Date object. minutesValue is an integer from 0 to 59.
- setMonth(monthValue)
- Sets the month for the current Date object. monthValue is an integer from 0 to 11 (where 0 is January, 1 is February, etc.).
- setSeconds(secondsValue)
- Sets the seconds of the time for the current Date object. secondsValue is an integer from 0 to 59.
- setTime(timeValue)
- Sets the value for the current Date object. timeValue is an integer representing the number of milliseconds since January 1, 1970 at 00:00:00.
- setYear(yearValue)
- Sets the year for the current Date object. yearValue is an integer greater than 1900.
- toGMTString()
- Returns the value of the current Date object in GMT as a string using Internet conventions in the form
Day, DD Mon YYYY HH:MM:SS GMT
- toLocaleString()
- Returns the value of the current Date object in the local time using local conventions.
- UTC(yearValue, monthValue, dateValue, hoursValue, minutesValue, secondsValue)
- Returns the number of milliseconds since January 1, 1970 at 00:00:00 GMT. yearValue is an integer greater than 1900. monthValue is an integer from 0 to 11. dateValue is an integer from 1 to 31. hoursValue is an integer from 0 to 23. minutesValue and secondsValue are integers from 0 to 59. hoursValue, minutesValue and secondsValue are optional.
Previous | Contents | Next
|