JavaScript - PowerPoint PPT Presentation

About This Presentation
Title:

JavaScript

Description:

... user pointing the browser to a new page, the script is unloaded along with the ... first window moves on to a new page, even though there is an active ... – PowerPoint PPT presentation

Number of Views:79
Avg rating:3.0/5.0
Slides: 136
Provided by: billg96
Learn more at: http://web.cs.wpi.edu
Category:

less

Transcript and Presenter's Notes

Title: JavaScript


1
JavaScript
2
math Object
  • abs
  • math.abs(-80) is 80
  • Many other functions

3
window Object
  • The window object represents the browser window
  • It doesnt have a name
  • That is, there is no variable that contains a
    reference to it
  • A reference to it is assumed when you use
    properties such as history or alert( )

4
window Object
  • Most browsers allow more than one window open at
    a time
  • Thus, implicit window reference refers only to
    the current window, the window that is displaying
    the HTML document that contains the JavaScript
    code currently being executed

5
window Object
  • To refer to some other window, you must have a
    reference to it
  • Use the open( ) method
  • This is also a method of a document, so the
    syntax should be window.open( ) or self.open( )

6
window Object
  • The Window object has a property named window and
    another named self
  • Both, implicitly, contain references to the
    window itself
  • window.history
  • window.alert(Hello there!)

7
window Object
  • The Window object has a property named window and
    another named self
  • First argument of open( ) specifies URL of page
    to displayed, or an empty string to open a blank
    window
  • var newwin open("otherpage.html")
  • newwin.creator self

8
window Object
  • Every JavaScript expression implicitly refers to
    the current window
  • Thus, code like j 0 is actually the same as
    window.j 0
  • Variables are nothing more than properties of the
    current window
  • Two variables with same name can be declared in
    different windows or frames without conflicting
    with each other

9
window Object
  • Every JavaScript expression implicitly refers to
    the current window
  • JavaScript code running in one window or frame
    can read and write variables declared by code in
    another window
  • Thus, if a top-level window has two frames and
    the following code in the first frame
  • parent.frames1.j 7
  • this is equivalent to the following code in the
    second frame
  • j 7

10
window Object
  • Every JavaScript expression implicitly refers to
    the current window
  • No really global variables across window and
    frames

11
window Object
  • Every JavaScript expression implicitly refers to
    the current window
  • When a page that contains a script is unloaded
    due to the user pointing the browser to a new
    page, the script is unloaded along with the page
    that contains it
  • What about the script variables?
  • Since they are properties of the window object,
    you might think they are still defined

12
window Object
  • Every JavaScript expression implicitly refers to
    the current window
  • When a page that contains a script is unloaded
    due to the user pointing the browser to a new
    page, the script is unloaded along with the page
    that contains it
  • If they were, however, this would be dangerous
  • A new script that was loaded would start off with
    some baggage

13
window Object
  • Every JavaScript expression implicitly refers to
    the current window
  • When a page that contains a script is unloaded
    due to the user pointing the browser to a new
    page, the script is unloaded along with the page
    that contains it
  • All user-defined properties (which includes all
    variables) are erased whenever a page is unloaded
  • The lifetime of scripts and of the variables they
    define is the same as the lifetime of the
    document object that contains the script

14
window Object
  • Garbage collection
  • JavaScript supports automatic garbage collection
  • Different techniques in Navigator 2.0, Navigator
    3.0, and Navigator 4

15
window Object
  • Garbage collection
  • Navigator 4 / JavaScript 1.2
  • Completely transparent

16
window Object
  • Navigator 3.0 / JavaScript 1.1
  • Uses reference counts
  • If JavaScript code running in a window object
    creates an object, o, and a reference to that
    object is stored in a variable of another window
    object, then o will continue to exist even after
    the window object that created it is closed or
    loads in a different page

17
window Object
  • Navigator 3.0 / JavaScript 1.0
  • A top-level window may be closed by the user, but
    the window object associated with it may continue
    to exist if a variable in another window object
    contains a reference to the window object that is
    closed

18
window Object
  • Navigator 2.0
  • All objects created by JavaScript code running in
    a particular window object allocate memory from a
    pool owned by the window object
  • When the window object is destroyed or when the
    document object containing the JavaScript program
    displayed in the window is unloaded, the entire
    pool of memory is freed at once

19
window Object
  • Navigator 2.0
  • Disadvantages
  • If an object is created in one window and a
    reference to that object is stored in a variable
    in a second window, that object will be destroyed
    when the first window moves on to a new page,
    even though there is an active reference to it
  • If the other window tries to use this reference,
    an error will result, possibly resulting in a
    browser crash

20
window Object
  • Navigator 2.0
  • Disadvantages
  • If a window never unloads, its associated memory
    will never be freed
  • One frame may serve as a navigation window
    allowing users to browse a large site in other
    frames or windows
  • These other frames or windows may load and unload
    pages frequently, but the navigation frame
    remains the same

21
window Object
  • Properties
  • closed
  • Read-only boolean specifying whether window
    object is closed
  • defaultStatus
  • String specifying default message appearing in
    status line
  • document
  • Reference to document object contained in window
    object

22
window Object
  • Properties
  • frames
  • An array of frame objects contained by this
    window object
  • history
  • A reference to the history object for this window
    object
  • length
  • The number of elements in the frames array
    read-only

23
window Object
  • Properties
  • location
  • A reference to the location object for this
    window object
  • name
  • String specifying name of the window object
  • navigator
  • A reference to the navigator object that applies
    to this and all other window objects

24
window Object
  • Properties
  • opener
  • A reference to the window object that called
    open() to create this window object
  • parent
  • A reference to the parent window (frame) object
    of the current window object
  • self
  • A reference to the window object itself

25
window Object
  • Properties
  • status
  • A string specifying the current contents of the
    status bar
  • top
  • A reference to the top-level window object that
    contains the current window object
  • window
  • A reference to the current window object

26
window Object
  • Methods
  • alert()
  • Display a simple message in a dialog box
  • window.alert(message)
  • Displays message in a dialog box
  • Dialog box contains an OK button that user can
    click to dismiss it
  • User can continue to interact with browser window
    while the dialog is displayed
  • JavaScript execution continues while the dialog
    is displayed
  • Used to display error messages
  • message is plain text, so can use newline
    characters to break your message across multiple
    lines

27
window Object
  • Methods
  • blur()
  • window.blur()
  • Takes keyboard focus from browser window
    specified by the window object
  • If this object is a frame object, then keyboard
    focus is given to the toplevel window object
    containing the frame object
  • The window object will be sent to the background,
    to the bottom of the window stack

28
window Object
  • Methods
  • clearTimeout()
  • window.clearTimeout(timeoutId)
  • Cancels the execution of code that has been
    deferred with the setTimeout() method
  • The timeoutId argument is a value returned by the
    call to setTimeout() and specifies which block of
    deferred code to cancel

29
window Object
  • Methods
  • close()
  • window.close()
  • Closes browser window specified by window
  • A window object can close itself by issuing
    self.close() or close()
  • If window is the only open window object, then it
    is closed and browser exits
  • In Navigator 3.0, only window objects opened by
    JavaScript can be closed by JavaScript

30
window Object
  • Methods
  • confirm()
  • window.confirm(question)
  • Displays argument question in a dialog box that
    pops up over window
  • Dialog contains OK and Cancel buttons
  • If user clicks OK, then confirm() returns true
  • If user clicks Cancel, the confirm() returns
    false
  • Blocks all user input to the browser window until
    user dismisses dialog by clicking on the OK or
    Cancel buttons

31
window Object
  • Methods
  • confirm()
  • JavaScript execution pauses until user response
  • The string question is plain text, so can use
    newline characters

32
window Object
  • Methods
  • focus()
  • window.focus()
  • Gives keyboard focus to browser window specified
    by window object
  • If window object is a frame, then keyboard focus
    is given to top-level window that contains that
    frame
  • When window object is given focus, it is brought
    forward, to top of window stack

33
window Object
  • Methods
  • open()
  • window.open(url, name, features)
  • url is string specifying url to be displayed in
    the new window, or the empty string for a blank
    window
  • name is a string specifying name for the new
    window object
  • This name can be used as value of the target
    attribute of the ltagt (window which displays
    result of clicking on link), ltmapgt (window which
    displays result of clicking on image), and ltformgt
    tags (window which displays result of form
    submission)

34
window Object
  • Methods
  • open()
  • window.open(url, name, features)
  • features is a string specifying features of
    browser window
  • If not specified, then new window object will
    have all standard features

35
window Object
  • Methods
  • open()
  • Returns a reference to a window object, either
    newly created or an existing one
  • If the name argument specifies an existing window
    object, then a reference to that window object is
    returned
  • The returned window object will display the url
    specified by url, but the features argument will
    be ignored

36
window Object
  • Methods
  • open()
  • If the name argument is not specified, or no
    window object with that name already exists, a
    new window object is created
  • The created window object displays the url
    specified by url and the size and controls
    specified by features
  • The name of the new window object is specified by
    name

37
window Object
  • Methods
  • open()
  • The features argument is a comma-separated list
    with the format featurevalue
  • For most features, value is yes or no
  • If feature appears and value is omitted, yes is
    assumed
  • If feature doesn't appear, no is assumed
  • toolbar
  • Browser toolbar with Back and Forward buttons

38
window Object
  • Methods
  • open()
  • The features argument is a comma-separated list
    with the format featurevalue
  • location
  • The input field for entering URL's directly into
    the browser
  • directories
  • Directory buttons, such as "What's New" and
    "What's Cool" in Netscape
  • status
  • The status line

39
window Object
  • Methods
  • open()
  • The features argument is a comma-separated list
    with the format featurevalue
  • menubar
  • The menu bar
  • scrollbars
  • Enables horizontal and vertical scrollbars when
    necessary
  • resizable
  • window object will have resize handles around its
    border

40
window Object
  • Methods
  • open()
  • The features argument is a comma-separated list
    with the format featurevalue
  • width
  • Width of window object in pixels
  • height
  • Height of window object in pixels

41
window Object
  • Methods
  • prompt()
  • window.prompt(message)
  • window.prompt(message, default)
  • Displays specified message in a dialog box that
    also contains a textual input field and OK,
    Clear, and Cancel buttons
  • If user clicks Cancel, prompt() returns null
  • If user clicks Clear, prompt() erases any text in
    the input field
  • If user clicks OK, prompt() returns the current
    value displayed in the input field (as a string)

42
window Object
  • Methods
  • prompt()
  • The default argument specifies text that
    initially appears in the input field
  • Blocks all user input to the browser window until
    user dismisses dialog by clicking on the OK or
    Cancel buttons
  • JavaScript execution pauses until user response

43
window Object
  • Methods
  • scroll()
  • window.scroll(x,y)
  • Moves the window object's document object within
    the window object, so that the specified x and y
    coordinates of the document object appear in the
    upper-left corner of the window object
  • scroll(0,0) places the top-left of the document
    object in the top-left corner of the window object

44
window Object
  • Methods
  • setTimeout()
  • window.setTimeout(code, delay)
  • Returns a timeout-id that can be passed to the
    clearTimeout() method to cancel the execution of
    code
  • Defers execution of code for delay milliseconds

45
window Object
  • Event handlers
  • onblur()
  • ltbody
  • onBlur "JavaScript statements"
  • gt
  • ltframeset
  • onBlur "JavaScript statements"
  • gt

46
window Object
  • Event handlers
  • onblur()
  • window.onblur handler_function
  • Defining the handler directly
  • window.onblur()
  • An explicit invocation of the handler

47
window Object
  • Event handlers
  • onblur()
  • Invoked by browser when browser window loses the
    input focus, either because the user has switched
    to some other window object, or because focus was
    explicitly transferred to another browser window
    with the window object blur() or focus() methods

48
window Object
  • Methods
  • onerror()
  • window.onerror handler_function
  • Defining the error handler
  • window.onerror(message, url, line)
  • Invoking the error handler
  • Customizing error handling
  • message specifies the error message for the error
    that occurred

49
window Object
  • Methods
  • onerror()
  • url specifies the URL of the document object in
    which the error occurred
  • line specifies the line number at which the error
    occurred

50
window Object
  • Methods
  • onfocus()
  • ltbody
  • onFocus "JavaScript statements"
  • gt
  • ltframeset
  • onFocus "JavaScript statements"
  • gt

51
window Object
  • Methods
  • onfocus()
  • window.onfocus handler_function
  • Defining the handler directly
  • window.onfocus()
  • An explicit invocation of the handler

52
window Object
  • Methods
  • onfocus()
  • Invoked by browser when browser window is given
    the input focus, either because the user has
    switched to this window object, or because focus
    was explicitly transferred to this browser window
    with the window object focus() method

53
window Object
  • Methods
  • onload()
  • ltbody onLoad "JavaScript
  • statements"
  • gt
  • ltframeset rows "row sizes"
  • cols "column sizes"
  • onLoad "JavaScript statements"gt

54
window Object
  • Methods
  • onload()
  • window.onload
  • Reference to handler
  • window.onload()
  • Explicit invocation of handler
  • Can use this handler to set a variable and to
    check the value of this variable before doing
    anything that depends on the complete document
    object being loaded

55
window Object
  • Methods
  • onunload()
  • ltbody onUnload "JavaScript
  • statements"
  • gt
  • ltframeset rows "row sizes"
  • cols "column sizes"
  • onUnload "JavaScript statements"gt

56
window Object
  • Methods
  • onunload()
  • window.onunload
  • Reference to handler
  • window.onunload()
  • Explicit invocation of handler
  • Can use this handler to set a variable and to
    check the value of this variable before doing
    anything that depends on the complete document
    object being loaded

57
document Object
  • Notation
  • window.document
  • document

58
document Object
  • Properties
  • alinkColor
  • Specifies color of activated links
  • anchors
  • Array of anchor objects, one for each hypertext
    target
  • document.anchorsj or document .anchor-name
  • anchors.length
  • Number of elements in anchors read-only

59
document Object
  • Properties
  • applets
  • An array of Java objects, one for each
    ltappletgt-tag
  • applets.length
  • Number of elements in applets
  • bgColor
  • A string specifying the background color
  • cookie
  • A string that specifies the value of a cookie

60
document Object
  • Properties
  • domain
  • A string that specifies the domain of the
    document object
  • embeds
  • An array of Java objects, one for each
    ltembedgt-tag
  • embeds.length
  • Number of elements in embeds read-only

61
document Object
  • Properties
  • fgColor
  • A string specifying the color of document text
  • forms
  • An array of forms objects, one for each
    ltformgt-tag
  • document.formsj or document .form_name
  • forms.length
  • Number of elements in forms read-only

62
document Object
  • Properties
  • images
  • An array of image objects, one for each image
    embedded in the document using the ltimggt-tag
  • document.imagesi or document .image_name
  • images.length
  • Number of elements in images read-only
  • lastModified
  • Read-only string that specifies date of most
    recent document change

63
document Object
  • Properties
  • linkColor
  • A string specifying color unvisited links
  • links
  • An array of link objects, one for each hypertext
    link
  • links.length
  • Number of elements in links read-only

64
document Object
  • Properties
  • location
  • A synonym for the URL property
  • plugins
  • A synonym for the embeds array
  • plugins.length
  • A synonym for embeds.length

65
document Object
  • Properties
  • referrer
  • A read-only string specifying the URL of the
    document object that contained the link that
    referred to the current document
  • title
  • A read-only string specifying the lttitlegt of the
    document object

66
document Object
  • Properties
  • URL
  • A read-only string specifying the URL of the
    document object
  • vlinkColor
  • A string specifying the color of visited links

67
document Object
  • Methods
  • clear( )
  • Erases contents of document object
  • close( )
  • Closes a document stream opened with open()
    method
  • open( )
  • Opens a stream to which document object contents
    can be written

68
document Object
  • Methods
  • write( )
  • Inserts the specified string into the document
    object currently being parsed, or into a document
    stream opened with open( )
  • writeln( )
  • Same as write but appends a newline character

69
document Object
  • Event handlers
  • onload
  • Invoked when document is loaded
  • Specified by onLoad attribute
  • onunload
  • Invoked when document is unloaded
  • Specified by onUnload attribute

70
document Object
  • HTML syntax
  • ltbody
  • background imageURL a background image
  • bgcolor color a background color
  • text color color of documents text
  • link color color for unvisited links
  • alink color color for activated links
  • vlink color color for visited links
  • onLoad handler onload event handler
  • onUnload handler onunload event handler
  • gt

71
form Object
  • Notation
  • document.form_name
  • document.formsform_number
  • document.forms.length

72
form Object
  • Properties
  • action
  • A string specifying the URL to which the form
    object is to be submitted
  • elements
  • An array of input elements that appear in the
    form object
  • Each element is a button, checkbox, hidden,
    password, radio, reset, select, submit, text, or
    textarea object

73
form Object
  • Properties
  • elements.length
  • Number of items in elements
  • encoding
  • String specifying the encoding method for form
    data
  • method
  • String specifying technique for submitting form
  • target
  • String specifying name of frame of window in
    which results of submitting form should be
    displayed

74
form Object
  • Methods
  • reset( )
  • Reset each of the input elements of the form to
    their default values
  • submit( )
  • Submit the form

75
form Object
  • Event handlers
  • onreset( )
  • Invoked just before elements of form are reset
  • Specified by onReset attribute
  • onsubmit( )
  • Invoked just before form is submitted
  • Specified by onSubmit attribute

76
form Object
  • HTML syntax
  • ltform
  • name form_name name of the form in
  • JavaScript
  • target window_name name of response
    window
  • action url submitted-to URL
  • method (get post) method of form
  • submission
  • enctype encoding how form data is encoded
  • onSubmit handler onsubmit( ) event handler
  • onReset handler onreset( ) event handler
  • gt

77
button Object
  • Notation
  • form.button_name
  • form.elementsj
  • form.elementsbutton_name

78
button Object
  • Properties
  • form
  • Read-only reference to form object that contains
    button object
  • name
  • Read-only string specifying name of the button
    object
  • type
  • Read-only string specifying type of form element
  • In this case, it is button

79
button Object
  • Properties
  • value
  • Read-only string specifying value displayed in
    the button object

80
button Object
  • Event handlers
  • onclick( )
  • Invoked when button is clicked

81
button Object
  • HTML syntax
  • ltinput
  • type button specifies that this is a button
  • value label text to appear within button
  • name name name to refer to button
  • onClick handler onclick( ) event handler
  • gt

82
checkbox Object
  • Notation
  • Single checkbox
  • form.checkbox_name
  • form.elementsj
  • form.elementscheckbox_name

83
checkbox Object
  • Notation
  • Group of checkboxes with same name
  • form.checkbox_namej
  • form.checkbox_name.length
  • form.elementsjk
  • form.elementsj.length
  • form.elementscheckbox_namej
  • formlelementscheckbox_name.length

84
checkbox Object
  • Properties
  • checked
  • Boolean value specifying whether checkbox object
    is checked or not
  • defaultChecked
  • Boolean value specifying the initial state of
    checkbox object read-only
  • form
  • Read-only reference to form object containing
    checkbox object

85
checkbox Object
  • Properties
  • name
  • Read-only string specifying name of checkbox
    object
  • type
  • Read-only string specifying type of form element
  • In this case, it is checkbox
  • value
  • String specifying value returned by checkbox
    object if it is selected when form is submitted

86
checkbox Object
  • Event handlers
  • onclick( )
  • Invoked when the checkbox is clicked

87
checkbox Object
  • HTML syntax
  • ltinput
  • type checkbox specifies that this is checkbox
  • name name name to refer to checkbox
  • value value value returned when selected
  • checked checkbox is initially checked
  • onClick handler onclick( ) event handler
  • gt

88
hidden Object
  • Notation
  • form.name
  • form.elementsj
  • form.elementsname

89
hidden Object
  • Properties
  • form
  • Read-only reference to containing form object
  • name
  • Read-only string specifying name of hidden object
  • type
  • Read-only string specifying type of this form
    element
  • In this case, it is hidden

90
hidden Object
  • Properties
  • value
  • String specifying data to be transmitted to
    server when form is submitted

91
hidden Object
  • HTML syntax
  • ltinput
  • type hidden specifies that this is hidden
    object
  • name name name to refer to hidden object
  • value value value transmitted when form
  • submitted
  • gt

92
password Object
  • Notation
  • form.name
  • form.elementsj
  • form.elementsname

93
password Object
  • Properties
  • form
  • Read-only reference to form object containing
    password object
  • name
  • Read-only string specifying name of password
    object
  • type
  • Read-only string specifying type of form element
  • In this case, it is password

94
password Object
  • Properties
  • value
  • Read-only string specifying password value
    entered by user

95
password Object
  • Methods
  • blur( )
  • Removes keyboard focus from password object
  • focus( )
  • Sets keyboard focus to password object
  • When focus is set, all keystrokes are
    automatically entered into this object

96
password Object
  • HTML syntax
  • ltinput
  • type password specifies this is password
    object
  • name name name to refer to password object
  • value default default value transmitted
    when
  • form is submitted
  • size integer number of characters wide of
    the
  • object
  • gt

97
radio Object
  • Notation
  • Always used in groups of mutually exclusive
    options that have same name
  • form.radio_name
  • form.radio_name.length
  • form.elementsjk
  • form.elementsj.length
  • form.elementsradio_namek
  • form.elementsradio_name.length

98
radio Object
  • Properties
  • checked
  • Boolean value specifying whether button is
    checked or not
  • defaultChecked
  • Read-only Boolean value specifying initial state
    of radio object
  • form
  • Read-only reference to form object containing
    radio object

99
radio Object
  • Properties
  • name
  • Read-only string specifying name of radio object
  • type
  • Read-only string specifying type of form element
  • In this case, it is radio

100
radio Object
  • Properties
  • value
  • String specifying value returned by radio button
    if it is selected when form is submitted

101
radio Object
  • Event handlers
  • onclick( )
  • Invoked when radio button is clicked

102
radio Object
  • HTML syntax
  • ltinput
  • type radio specifies this is radio button
  • name name name to refer to this button
  • value value value returned when button is
  • selected
  • checked button is initially checked
  • onClick handler onclick( ) event handler
  • gt

103
reset Object
  • Notation
  • form.name
  • form.elementsj
  • form.elementsname

104
reset Object
  • Properties
  • form
  • Read-only reference to form object containing
    reset object
  • name
  • Read-only string specifying name of reset object
  • type
  • Read-only string specifying type of form element
  • In this case, it is reset

105
reset Object
  • Properties
  • value
  • Read-only string specifying text to appear in
    button

106
reset Object
  • Event handlers
  • onclick( )
  • Invoked when reset button is clicked

107
reset Object
  • HTML syntax
  • ltinput
  • type reset specifies this is reset button
  • value label text to appear in button
  • name name name to refer to this button
  • onClick handler onclick( ) event handler
  • gt

108
select Object
  • Notation
  • form.name
  • form.elementsj
  • form.elementsname

109
select Object
  • Properties
  • form
  • Read-only reference to form object containing
    select object
  • length
  • Read-only integer specifying number of elements
    in the options array
  • name
  • Read-only string specifying name of select object

110
select Object
  • Properties
  • options
  • An array of option objects, each of which
    describes one of the options displayed within the
    select object
  • selectedIndex
  • A read-only integer specifying the index of the
    selected option within the select object
  • If the select object allows multiple selections,
    then this property only specifies the index of
    the first selected item or -1 if none are selected

111
select Object
  • Properties
  • type
  • Read-only string specifying type of form element
  • In this case, it is either select-one or
    select-multiple

112
select Object
  • Event handlers
  • onchange( )
  • Invoked when the user selects or deselects an
    item
  • onblur( )
  • Invoked when a user action causes the select
    object to lose the keyboard focus
  • onfocus( )
  • Invoked when a user action causes the select
    object to gain the keyboard focus

113
select Object
  • HTML syntax
  • ltselect
  • name name name identifying the
  • object
  • size integer number of visible options
  • in object
  • multiple multiple options may be
    selected
  • onChange handler onchange( ) event
  • handler
  • onBlur handler onblur( ) event handler
  • onFocus handler onfocus( ) event handler
  • gt

114
options Object
  • Notation
  • select.optionsj

115
options Object
  • Properties
  • defaultSelected
  • Read-only boolean value specifying whether this
    option object is selected by default
  • index
  • Read-only integer specifying index of this option
    object within the array of options
  • selected
  • Boolean value specifying whether this option
    object is currently selected

116
options Object
  • Properties
  • text
  • Text that describes the option object
  • value
  • Specifies value to be passed to server if this
    option object is selected when form is submitted

117
options Object
  • Constructor
  • new Option(text, value,
  • defaultSelected, selected)

118
options Object
  • HTML syntax
  • ltoption
  • value value value returned when form
  • submitted
  • selected whether option is initially
  • selected
  • gt

119
submit Object
  • Notation
  • form.name
  • form.elementsj
  • form.elementsname

120
submit Object
  • Properties
  • form
  • Read-only reference to form object containing
    submit object
  • name
  • Read-only string specifying name of submit object
  • type
  • Read-only string specifying type of form element
  • In this case, it is submit

121
submit Object
  • Properties
  • value
  • Read-only string specifying text to appear in
    button

122
submit Object
  • Event handlers
  • onclick( )
  • Invoked when submit button is clicked

123
submit Object
  • HTML syntax
  • ltinput
  • type submit specifies this is submit button
  • value label text to appear in button
  • name name name to refer to this button
  • onClick handler onClick event handler
  • gt

124
text Object
  • Notation
  • form.name
  • form.elementsj
  • form.elementsname

125
text Object
  • Properties
  • defaultValue
  • Read-only string specifying initial value to
    appear in input field
  • name
  • Read-only string specifying name of text object
  • type
  • Read-only string specifying type of form element
  • In this case, it is text

126
text Object
  • Properties
  • value
  • String specifying value contained in input field

127
text Object
  • Methods
  • blur( )
  • Remove keyboard focus from text object
  • focus( )
  • Set keyboard focus to text object
  • When focus is set, all keystrokes are
    automatically entered into this object
  • select( )
  • Highlight all text in text object
  • All future input will replace this highlighted
    text

128
text Object
  • Event handlers
  • onblur( )
  • Invoked when a user action causes the text object
    to lose keyboard focus
  • onchange( )
  • Invoked when the user changes the value in the
    text object and move the keyboard focus elsewhere
  • onfocus( )
  • Invoked when a user action causes the text object
    to gain the keyboard focus

129
text Object
  • HTML syntax
  • ltinput
  • type text specifies that this is a text object
  • name name used to refer to this text
    object
  • value default default value transmitted
    when
  • form is submitted
  • size integer number of characters in text
    object
  • maxlength integer maximum allowed number of
    input
  • characters
  • onBlur handler onblur( ) event hander
  • onChange handler onchange( ) event handler
  • onFocus handler onfocus( ) event handler
  • gt

130
textarea Object
  • Notation
  • form.name
  • form.elementsj
  • form.elementsname

131
textarea Object
  • Properties
  • defaultValue
  • Read-only string specifying initial value to
    appear in input field
  • name
  • Read-only string specifying name of textarea
    object
  • type
  • Read-only string specifying type of form element
  • In this case, it is textarea

132
textarea Object
  • Properties
  • value
  • String specifying value contained in the textarea
    object

133
textarea Object
  • Methods
  • blur( )
  • Remove keyboard focus from textarea object
  • focus( )
  • Set keyboard focus to textarea object
  • When focus is set, all keystrokes are
    automatically entered into this object

134
textarea Object
  • Event handlers
  • onblur( )
  • Invoked when a user action causes the textarea
    object to lose keyboard focus
  • onchange( )
  • Invoked when the user changes the value in the
    textarea object and move the keyboard focus
    elsewhere
  • onfocus( )
  • Invoked when a user action causes the textarea
    object to gain the keyboard focus

135
textarea Object
  • HTML syntax
  • lttextarea
  • name name name of object
  • rows integer number of lines of object
  • columns integer character width of object
  • wrap offvirtualphysical word wrapping
  • onBlur handler onblur( ) event handler
  • onChange handler onchange( ) event
  • handler
  • onFocus handler onfocus( ) event handler
  • gt
Write a Comment
User Comments (0)
About PowerShow.com