javascript手冊-h

王朝html/css/js·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

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="hiddenName"

[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.

Hidden object example

Click some of these objects, then click the "Display value" button

to see the value of the last object clicked.

Soul and R&B

Jazz

Classical

Red Orange Yellow

相关

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 + "<P>")

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

newWindow.location.protocol + "<P>")

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

newWindow.location.host + "<P>")

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

newWindow.location.hostName + "<P>")

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

newWindow.location.port + "<P>")

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

newWindow.location.pathname + "<P>")

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

newWindow.location.search + "<P>")

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

newWindow.location.hash + "<P>")

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

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有  導航