站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题javascript手冊-h

javascript手冊-h

摘要: javascript
<textarea readonly style="border:none;font-family:Courier New;line-height:150%;width:760px;overflow-y:visible">

hash property

A string beginning with a hash mark (#) that specifies an anchor name in the URL.

语法

1. links[index].hash

2. location.hash

index is an integer representing a link object.

Property of

link, location

描述

The hash property specifies a portion of the URL.

You can set the hash property at any time, although it is safer to set the href property to change a location. If the hash that you specify cannot be found in the current location, you will get an error.

See RFC 1738 for complete information about the hash.

例子

See the 例子 for the anchor object and the href property.

相关

  • host, hostname, href, pathname, port, protocol, search properties

    hidden object

    A text object that is suppressed from form display on an htm form. A hidden object is used for passing name/value pairs when a form submits.

    语法

    To define a hidden object:

    <input
    
       TYPE="hidden"
    
       NAME=""
    
       [VALUE="textValue"]>
    
    
    NAME="hiddenName" specifies the name of the hidden object. You can access this value using the name property.
    VALUE="textValue" specifies the initial value of the hidden object.

    To use a hidden object's properties:

    1. hiddenName.propertyName
    
    2. formName.elements[index].propertyName
    
    
    hiddenName is the value of the NAME attribute of a hidden object.
    formName is either the value of the NAME attribute of a form object or an element in the forms array.
    index is an integer representing a hidden object on a form.
    propertyName is one of the properties listed below.

    Property of

  • form

    描述

    A hidden object is a form element and must be defined within a <form> tag.

    A hidden object cannot be seen or modified by a user, but you can programatically change the value of the object by changing its value property. You can use hidden objects for client/server communication.

    Properties

  • name reflects the NAME attribute
  • value reflects the current value of the hidden object

    Methods

  • None.

    Event handlers

  • None.

    例子

    The following example uses a hidden object to store the value of the last object the user clicked. The form contains a "Display hidden value" button that the user can click to display the value of the hidden object in an Alert dialog box. <htm> &lt;head&gt; <TITLE>Hidden object example</TITLE> &lt;/head&gt; &lt;body&gt; <B>Click some of these objects, then click the "Display value" button <BR>to see the value of the last object clicked.</B> &lt;form NAME="form1"&gt; &lt;input TYPE="hidden" NAME="hiddenObject" VALUE="None"&gt; <P> &lt;input TYPE="button" VALUE="Click me" NAME="button1" onClick="document.form1.hiddenObject.value=this.value"&gt; <P> &lt;input TYPE="radio" NAME="musicChoice" VALUE="soul-and-r&b" onClick="document.form1.hiddenObject.value=this.value"&gt; Soul and R&B &lt;input TYPE="radio" NAME="musicChoice" VALUE="jazz" onClick="document.form1.hiddenObject.value=this.value"&gt; Jazz &lt;input TYPE="radio" NAME="musicChoice" VALUE="classical" onClick="document.form1.hiddenObject.value=this.value"&gt; Classical <P> &lt;select NAME="music_type_single" onFocus="document.form1.hiddenObject.value=this.options[this.selectedIndex].text"&gt; &lt;option SELECTED&gt; Red &lt;option&gt; Orange &lt;option&gt; Yellow &lt;/select&gt; <P>&lt;input TYPE="button" VALUE="Display hidden value" NAME="button2" onClick="alert('Last object clicked: ' + document.form1.hiddenObject.value)"&gt; &lt;/form&gt; &lt;/body&gt; </htm>

    相关

  • cookie property

    history object

    Contains information on the URLs that the client has visited within a window. This information is stored in a history list, and is accessible through the Navigator's Go menu.

    语法

    To use a history object:

    1. history.propertyName
    
    2. history.methodName(parameters)
    
    
    propertyName is one of the properties listed below.
    methodName is one of the methods listed below.

    Property of

  • document

    描述

    The history object is a linked list of URLs the user has visited, as shown in the Navigator's Go menu.

    Properties

  • length reflects the number of entries in the history object

    Methods

  • back
  • forward
  • go

    Event handlers

  • None.

    例子

    Example 1. The following example goes to the URL the user visited three clicks ago in the current window.

    history.go(-3)

    Example 2. You can use the history object with a specific window or frame. The following example causes window2 to go back one item in its window (or session) history:

    window2.history.back()

    Example 3. The following example causes the second frame in a frameset to go back one item:

    parent.frames[1].history.back()

    Example 4. The following example causes the frame named frame1 in a frameset to go back one item:

    parent.frame1.history.back()

    Example 5. The following example causes the frame named frame2 in window2 to go back one item:

    window2.frame2.history.back()

    相关

  • location object

    host property

    A string specifying the hostname:port portion of the URL.

    语法

    1. links[index].host
    
    2. location.host
    
    

    index is an integer representing a link object.

    Property of

    link, location

    描述

    The host property specifies a portion of the URL. The host property is the concatenation of the hostname and port properties, separated by a colon. When the port property is null, the host property is the same as the hostname property.

    You can set the host property at any time, although it is safer to set the href property to change a location. If the host that you specify cannot be found in the current location, you will get an error.

    See Section 3.1 of RFC 1738 for complete information about the hostname and port.

    例子

    See the 例子 for the href property.

    相关

  • hash, hostname, href, pathname, port, protocol, search properties

    hostname property

    A string specifying the host and domain name, or IP address, of a network host.

    语法

    1. links[index].hostname
    
    2. location.hostname
    
    

    index is an integer representing a link object.

    Property of

    link, location

    描述

    The hostname property specifies a portion of the URL. The hostname property is a substring of the host property. The host property is the concatenation of the hostname and port properties, separated by a colon. When the port property is null, the host property is the same as the hostname property.

    You can set the hostname property at any time, although it is safer to set the href property to change a location. If the hostname that you specify cannot be found in the current location, you will get an error.

    See Section 3.1 of RFC 1738 for complete information about the hostname.

    例子

    See the 例子 for the href property.

    相关

  • hash, host, href, pathname, port, protocol, search properties

    href property

    A string specifying the entire URL.

    语法

    1. links[index].href
    
    2. location.href
    
    

    index is an integer representing a link object.

    Property of

    link, location

    描述

    The href property specifies the entire URL. Other location object properties are substrings of the href property. You can set the href property at any time.

    Omitting a property name from the location object is equivalent to specifying location.href. For example, the following two statements are equivalent and set the URL of the current window to the Netscape home page:

    window.location.href="http://www.netscape.com/" window.location="http://www.netscape.com/"

    See RFC 1738 for complete information about the URL.

    例子

    In the following example, the window.open statement creates a window called newWindow and loads the specified URL into it. The document.write statements display all the properties of newWindow.location in a window called msgWindow.

    newWindow=window.open
    
       ("http://home.netscape.com/comprod/products/navigator/
    
       version_2.0/script/script_info/objects.htm#checkbox_object")
    
    msgWindow.document.write("newWindow.location.href = " +
    
       newWindow.location.href + "

    ") msgWindow.document.write("newWindow.location.protocol = " + newWindow.location.protocol + "

    ") msgWindow.document.write("newWindow.location.host = " + newWindow.location.host + "

    ") msgWindow.document.write("newWindow.location.hostName = " + newWindow.location.hostName + "

    ") msgWindow.document.write("newWindow.location.port = " + newWindow.location.port + "

    ") msgWindow.document.write("newWindow.location.pathname = " + newWindow.location.pathname + "

    ") msgWindow.document.write("newWindow.location.search = " + newWindow.location.search + "

    ") msgWindow.document.write("newWindow.location.hash = " + newWindow.location.hash + "

    ") msgWindow.document.close()

    The previous example displays output such as the following:

    newWindow.location.href =
    
       http://home.netscape.com/comprod/products/navigator/
    
       version_2.0/script/script_info/objects.htm#checkbox_object
    
    newWindow.location.protocol = http:
    
    newWindow.location.host = home.netscape.com
    
    newWindow.location.hostName = home.netscape.com
    
    newWindow.location.port =
    
    newWindow.location.pathname =
    
       /comprod/products/navigator/version_2.0/script/
    
       script_info/objects.htm
    
    newWindow.location.search =
    
    newWindow.location.hash = #checkbox_object
    
    

    相关

  • hash, host, hostname, pathname, port, protocol, search properties
    </textarea>
    ↑返回目录
    前一篇: javascript手冊-g
    后一篇: javascript手冊-i