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

以下的一些"方法"可用在JavaScript:

  • abs
  • acos
  • alert
  • anchor
  • asin
  • assign
  • atan
  • back
  • big
  • blink
  • blur
  • bold
  • ceil
  • charAt
  • clear
  • clearTimeout
  • click
  • close
  • confirm
  • cos
  • eval
  • exp
  • fixed
  • floor
  • focus
  • fontcolor
  • fontsize
  • forward
  • getDate
  • getDay
  • getHours
  • getMinutes
  • getMonth
  • getSeconds
  • getTime
  • getTimeZoneoffset
  • getYear
  • go
  • indexOf
  • italics
  • lastIndexOf
  • link
  • log
  • max
  • min
  • open
  • parse
  • pow
  • prompt
  • random
  • round
  • select
  • setDate
  • setHours
  • setMinutes
  • setMonth
  • setSeconds
  • setTimeout
  • setTime
  • setYear
  • sin
  • small
  • sqrt
  • strike
  • sub
  • submit
  • substring
  • sup
  • tan
  • toGMTString
  • toLocaleString
  • toLowerCase
  • toString
  • toUpperCase
  • UTC
  • write
  • writeln

  • abs method

    Returns the absolute value of its argument.

    Syntax

    abs(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.


    acos method

    Returns the arc cosine (in radians) of its argument.

    Syntax

    acos(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.

    See also

  • asin, atan, cos, sin, tan methods

    alert method

    Displays an Alert dialog box with a message and an OK button.

    Syntax

    alert("message")

    The argument message is any string.

    Description

    Use the alert method to display a message that does not require a user decision. The message argument specifies a message that the dialog box contains.

    Applies to

    window

    Examples

    In the following example, the testValue function checks the name entered by a user in the text element of a form to make sure that it is no more than eight characters in length. This example uses the alert method to prompt the user of an application to enter a valid value.

    function testValue(textElement) {
       if (textElement.length > 8) {
          alert("Please enter a name that is 8 characters or less")
       }
    }
    You can call the testValue function in the onBlur event handler of a form's text element, as shown in the following example:
    Name: <INPUT TYPE="text" NAME="userName" onBlur="testValue(userName)">

    See also

  • confirm, prompt methods

    anchor method

    Causes the calling string object to be a named anchor by surrounding it with HTML anchor tags, <A NAME=...> </A>.

    Syntax

    string.anchor(name)

    The argument name can be any string.

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.

    See also

  • link method

    asin method

    Returns the arc sine (in radians) of its argument.

    Syntax

    asin(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.

    See also

  • acos, atan, cos, sin, tan methods

    assign method

    Sets location.href so you don't have to type ".href" complements toString().

    Syntax

    assign()

    Description

    Do not call the assign method. It exists so you can use 'location=...' instead of 'location.href=...'. xxx Description to be supplied.

    Applies to

    location

    Examples

    xxx Examples to be supplied.


    atan method

    Returns the arc tangent (in radians) of its argument.

    Syntax

    atan(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.

    See also

  • acos, asin, cos, sin, tan methods

    back method

    Loads the previous URL in the history list.

    Syntax

    back()

    Description

    This method performs the same action as a user choosing the Back button in the Navigator. The back method is the same as go(-1).

    Applies to

    history

    Examples

    xxx Examples to be supplied.

    See also

  • forward, go methods

    big method

    Causes the calling string object to be displayed in big font by surrounding it with HTML big font tags, <BIG> and </BIG>.

    Syntax

    big()

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.

    See also

  • fontsize, small methods

    blink method

    Causes the calling string object to blink by surrounding it with HTML blink tags, <BLINK> ... </BLINK>.

    Syntax

    blink()

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.

    See also

  • bold, italics, strike methods

    blur method

    For password, text, and textArea, removes focus to the object.

    Syntax

    blur()

    Description

    Use the blur method to remove focus from a specific form element.

    Applies to

    password, text, textArea

    Examples

    xxx Examples to be supplied.

    See also

  • focus, select methods

    bold method

    Causes the calling string object to be displayed as bold by surrounding it with HTML bold tags, <B> ... </B>.

    Syntax

    bold()
    NOTE: For Beta4, use B() for this method.

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.

    See also

  • blink, italics, strike methods

    ceil method

    Returns the least integer greater than or equal to its argument.

    Syntax

    ceil(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.

    See also

  • floor method

    charAt method

    Returns the character at the specified index.

    Syntax

    charAt(index)

    index is any integer from 0 to string.length() - 1.

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.

    See also

  • indexOf, lastIndexOf methods

    clear method

    Clears the window.

    Syntax

    clear()

    Description

    xxx Description to be supplied.

    Applies to

    document

    Examples

    xxx Examples to be supplied.


    clearTimeout method

    Cancels a timeout that was set with the setTimeout method.

    Syntax

    clearTimeout(timeoutID)

    timeoutID is a timeout setting that was returned by a previous call to the setTimeout method.

    Description

    xxx Description to be supplied. Applies to

    window

    Examples

    xxx Examples to be supplied.

    See also

  • setTimeout

    click method

    Simulates a mouse click on the calling form element.

    Syntax

    click()

    Description

    The effect of the click method varies according to the calling element:

  • For button, reset, and submit, xxx.
  • For a radioButton, selects a radio button.
  • For a checkbox, checks the check box and sets its value to on.
  • For a selection, sets its value.

    Applies to

    button, checkbox, radioButton, reset, selection, submit

    Examples

    xxx Examples to be supplied.


    close method

    For document and window, closes the window. xxx Not yet implemented in Beta 4.

    Syntax

    close()

    Description

    Document description to be supplied.

    The close method closes the current window.

    Applies to

    document, window

    Examples

    Any of the following examples close the current window:

    window.close()
    self.close()
    close()

    See also

  • open method

    confirm method

    Displays a Confirm dialog box with the specified message and OK and Cancel buttons.

    Syntax

    confirm("message")

    The argument message is any string.

    Description

    Use the confirm method to ask the user to make a decision that requires either an OK or a Cancel. The message argument specifies a message that prompts the user for the decison. The confirm method returns true if the user chooses OK and false if the user chooses Cancel.

    Applies to

    window

    Examples

    This example uses the confirm method in the confirmCleanUp function to confirm that the user of an application really wants to quit. If the user chooses OK, the custom cleanUp() function closes the application.

    function confirmCleanUp() {
       if (confirm("Are you sure you want to quit this application?")) {
          cleanUp()
       }
    }
    You can call the confirmCleanUp function in the onClick event handler of a form's pushbutton, as shown in the following example:
    <INPUT TYPE="button" VALUE="Quit" onClick="confirmCleanUp()">

    See also

  • alert, prompt methods

    cos method

    Returns the cosine of its argument. The argument is in radians.

    Syntax

    cos(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.

    See also

  • acos, asin, atan, sin, tan methods

    eval function

    The eval function is a function built-in to JavaScript. It is not a method associated with any object, but is part of the language itself.

    Syntax

    eval(expression)

    Description

    The eval function takes a JavaScript arthimetic expression as its argument and returns the value of the argument as a number.

    Example

    Both of the uses of eval in the following example assign the value 42 to the variable result.

    x = 6
    result = eval((3+3)*7)
    result = eval(x*7)
    

    exp method

    Returns e to the power of its argument, i.e. ex, where x is the argument, and e is Euler's constant, the base of the natural logarithms.

    Syntax

    exp(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.

    See also

  • log method

    fixed method

    Causes the calling string object to be displayed in fixed-pitch font in HTML by surrounding it with typewriter text tags, <fixed> ... </fixed>.

    Syntax

    fixed()
    NOTE: For Beta4, use TT() for this method.

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.


    floor method

    Returns the greatest integer less than or equal to its argument.

    Syntax

    floor(arg)

    Applies to

    Math

    Examples

    xxx Examples to be supplied.

    See also

  • ceil method

    focus method

    For password, text, and textArea, gives focus to the object.

    Syntax

    focus()

    Description

    Use the focus method to navigate to a specific form element and give it focus. You can then either programatically enter a value in the element or let the user enter a value.

    Applies to

    password, text, textArea

    Examples

    In the following example, the checkPassword function confirms that a user has entered a valid password. If the password is not valid, the focus method returns focus to the password field and the select method highlights it so the user can re-enter the password.

    function checkPassword(userPass) {
       if (badPassword) {
          alert("Please enter your password again.")
          userPass.focus()
          userPass.select()
       }
    }
    This example assumes that the password is defined as:
    <INPUT TYPE=password NAME=userPass>

    See also

  • blur, select methods

    fontcolor method

    Causes the calling string object to be displayed in the specified color by surrounding it with HTML font color tags, <FONTCOLOR=color> ... </FONTCOLOR>.

    Syntax

    fontcolor(color)

    The argument to the method, color, must be a string containing a hashmark (#) followed by a triplet of hexadecimal number pairs. These three pairs represent the red, green, and blue values for the desired color, respectively.

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.


    fontsize method

    Causes the calling string object to be displayed in the specified font size by surrounding it with HTML font size tags, <FONTSIZE=size> ... </FONTSIZE>.

    Syntax

    fontsize(size)

    The argument to the method, size, must be an integer between one and seven.

    Description

    xxx Description to be supplied.

    Applies to

    string

    Examples

    xxx Examples to be supplied.

    See also

  • big, small methods
  • [1] [2] [3] [4] 下一页


  • 上一篇文章:

  • 下一篇文章:
  • 相关文章