| 网站首页 | 文章中心 | 电子书下载 | 矢量图库 | 视频教程 | 素材下载 | 程序代码下载 | JS代码 | 论坛 | 
常用软件类:
|杀毒安全 |联络聊天 |网络软件 |多媒体类 |系统工具 |图形图像 |系统工具 |应用软件 |行业软件
开发设计类:
|动画制作 |图像处理 |3D设计 |操作系统 |站长学院 |网络相关 |WEB设计 |数据库类 |程序开发
JavaScript的对象
作者:佚名    文章来源:网络    点击数:    更新时间:2006-9-20
 

The following objects are available in JavaScript:

  • anchor
  • applet
  • button
  • checkbox
  • Date
  • document
  • form
  • history
  • link
  • location
  • Math
  • password
  • radioButton
  • reset
  • selection
  • string
  • submit
  • text
  • textArea
  • window
  • NOTE: Each object topic indicates whether the object is part of the client (in Navigator), server (in LiveWire), or is common (built-in to JavaScript). Server objects are not included in this version of the documentation.


    anchor object (client)

    An anchor is a piece of text identified as the target of a hypertext link.

    Syntax

    To define an anchor, use standard HTML syntax :

    <A NAME="anchorName"
       anchorText
    </A>
    
    

    NAME specifies a tag that becomes an available hypertext target within the current document.
    anchorText specifies the text to display at the anchor.

    Description

    You can reference the anchor objects in your code by using the anchors property of the document object. The anchors property is an array that contains an entry for each anchor in a document.

    xxx to be supplied

    Properties

  • xxx to be supplied

    Methods

  • xxx to be supplied

    Event handlers

    None.

    Examples

    <A NAME="javascript_intro"><H2>Welcome to JavaScript</H2></A>

    See also

  • link object
  • anchors property

    applet object (client)

    Represents a Java applet. xxx NYI.

    Syntax

    xxx to be supplied

    Description

    The applet object executes applets written in Java, not JavaScript. Java applets execute only on Netscape 2.0 and HotJava, and only on 32-bit platforms, such as Windows 95, Windows NT, and Unix. They do not execute on the 16-bit Windows platforms, such as Windows 3.1.

    Properties

  • length

    Methods

  • xxx to be supplied

    Event handlers

  • xxx to be supplied

    Examples

    xxx to be supplied

    See also

  • xxx to be supplied

    button object (client)

    A button object is a pushbutton on an HTML form.

    Syntax

    <INPUT
    
       TYPE="button"
       NAME="objectName"
       VALUE="buttonText"
       [onClick="handlerText"]>
    
    
    NAME specifies the name of the button object as a property of the enclosing form object and can be accessed using the name property. VALUE specifies the label to display on the button face and can be accessed using the value property.

    Description

    The button object is a custom button that you can use to perform an action you define.

    Properties

  • name
  • value

    Methods

  • click

    Event handlers

  • onClick

    Examples

    A custom button does not necessarily load a new page into the client; it merely executes the script specified by the onClick event handler. In the following example, myfunction() is a JavaScript function.

    <INPUT TYPE="button" VALUE="Calculate" NAME="calc_button" onClick="myfunction(this.form)">

    See also

  • reset and submit objects

    checkbox object (client)

    A checkbox object is a checkbox on an HTML form. A checkbox is a toggle switch that lets the user set a value on or off.

    Syntax

    To define a checkbox, use standard HTML syntax with the addition of the onClick event handler:

    <INPUT
    
       TYPE="checkbox"
       NAME="objectName"
       [CHECKED]
       [onClick="handlerText"]>
    
       textToDisplay
    

    Description

    Use the checked property to specify whether the checkbox is currently checked. Use the defaultChecked property to specify whether the checkbox is checked when the form is loaded.

    Properties

  • checked
  • defaultChecked
  • name
  • value

    Methods

  • click

    Event handlers

  • onClick

    Examples

    <B>Specify your music preferences (check all that apply):</B> <BR><INPUT TYPE="checkbox" NAME="musicpref_rnb" CHECKED> R&B <BR><INPUT TYPE="checkbox" NAME="musicpref_jazz" CHECKED> Jazz <BR><INPUT TYPE="checkbox" NAME="musicpref_blues" CHECKED> Blues <BR><INPUT TYPE="checkbox" NAME="musicpref_newage" CHECKED> New Age

    See also

  • xxx to be supplied

    Date object (common)

    JavaScript has a date object that enables you to work with dates and times. JavaScript handles dates very similar to the way Java handles dates: They have many of the same date methods, and both languages store dates internally as the number of milliseconds since January 1, 1970 00:00:00.

    Syntax

    To create a date object:

    varName = new Date(parameters)
    
    where varName is a JavaScript variable name for the date object being created; it can be a new object or a property of an existing object.

    The parameters for the Date constructor can be any of the following:

    • Nothing: creates today's date and time. For example, today = new Date()
    • A string representing a date in the following form: "Month day, year hours:minutes:seconds". For example, Xmas95= new Date("December 25, 1995 13:30:00") If you omit hours, minutes, or seconds, the value will be set to zero.
    • A set of integer values for year, month, and day. For example, Xmas95 = new Date(95,11,25)
    • A set of values for year, month, day, hour, minute, and seconds For example, Xmas95 = new Date(95,11,25,9,30,0)

    To use date methods:

    dateObj.methodName(parameters)
    

    Exceptions: The UTC and parse methods of date are static methods that you use as follows:

    Date.UTC(params)
    Date.parse(params)
    

    Description

    JavaScript does not have a date data type. However, the date object and its methods enable you to work with dates and times in your applications.

    The date object has a large number of methods for setting, getting, and manipulating dates.

    Properties

    None.

    Methods

  • getDate
  • getDay
  • getHours
  • getMinutes
  • getMonth
  • getSeconds
  • getTime
  • getTimeZoneoffset
  • getYear
  • parse
  • setDate
  • setHours
  • setMinutes
  • setMonth
  • setSeconds
  • setYear
  • toString
  • toGMTString
  • toLocaleString
  • UTC

    Event handlers

    None. Built-in objects do not have event handlers.

    Examples

    xxx to be supplied

    See also

  • xxx to be supplied

    document object (client)

    The document object contains information on the current document.

    Syntax

    To define a document object, use standard HTML syntax with the addition of the onLoad and onUnLoad event handlers:

    <BODY
    
       BACKGROUND="backgroundImage"
       BGCOLOR="#backgroundColor"
       FGCOLOR="#foregroundColor"
       LINK="#unfollowedLinkColor"
       ALINK="#activatedLinkColor"
       VLINK="#followedLinkColor"
       [onLoad="handlerText"]
       [onUnLoad="handlerText"]>
    
    </BODY>
    
    

    BGCOLOR, FGCOLOR, LINK, ALINK, and VLINK are color names or color specifications in the format "#rrggbb".

    Description

    The <BODY>... tag encloses an entire document, which is defined by the current URL. The entire body of the document (all other HTML elements for the document) goes within the <BODY>... tag.

    You can reference the anchors, forms, and links of a document by using the anchors, forms, and links properties. These properties are arrays that contain an entry for each anchor, form, or link in a document.

    The document object's title property reflects the contents of <TITLE>.... Other properties reflect the contents of the document; for example, bgColor reflects the background color, and lastModified reflects the time last modified. Some of the properties are reflections from HTML attributes; for example, the links property is a reflection of all the links in the document, and the forms property is a reflection of all the forms in the document.

    Properties

  • alinkColor
  • anchors
  • bgColor
  • fgColor
  • forms
  • lastModified
  • linkColor
  • links
  • loadedDate
  • location
  • referrer
  • title
  • vlinkColor

    Methods

  • clear
  • close
  • open
  • write
  • writeln

    Event handlers

  • onLoad
  • onUnLoad

    Examples

    xxx to be supplied

    See also

  • window object

    form object (client)

    A form lets users input text and make choices from form objects such as checkboxes, radio buttons, and selection lists. You can also use a form to post data to or retrieve data from a server.

    Syntax

    To define a form, use standard HTML syntax with the addition of the onSubmit event handler:

    <FORM
    
       NAME="objectName
       TARGET="windowName"
       ACTION="serverURL"
       METHOD=GET | POST
       [onSubmit="handlerText"]>
    
    </FORM>
    
    

    TARGET specifies the window that form responses go to. When you submit a form with a TARGET attribute, instead of seeing the server's responses in the same window that contained the form, you see them in a (possibly new) window.
    ACTION specifies the URL of the server to which form field input information is sent. METHOD specifies how information is sent to the server specified by ACTION. GET (the default) appends the input information to the URL which on most receiving systems becomes the value of the environment variable QUERY_STRING. POST sends the input information in a data body which is available on stdin with the data length set in the environment variable CONTENT_LENGTH.

    Description

    Each form in a document corresponds to a distinct object.

    You can reference the form objects in your code by using the forms property of the document object. The forms property is an array that contains an entry for each form in a document.

    You can reference a form's elements in your code by using the elements property. The elements property is an array that contains an entry for each element (such as a checkbox, radioButton, or text object) in a form.

    Properties

  • action
  • elements
  • method
  • name
  • target

    Methods

  • submit

    Event handlers

  • onSubmit

    Examples

    xxx to be supplied

    See also

  • elements, forms properties
  • [1] [2] [3] 下一页


  • 相关文章