Hidden object example
2007-11-27 17:52:21 来源:WEB开发网hash property
A string beginning with a hash mark (#) that specifies an anchor name in the URL.
语法
1. links[index].hash2. 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.
相关
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 objects properties:
1. hiddenName.propertyName2. formName.elements[index].propertyNamehiddenName 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
描述
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
Methods
Event handlers
例子
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.to see the value of the last object clicked.
相关
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 Navigators Go menu.
语法
To use a history object:
1. history.propertyName2. history.methodName(parameters)propertyName is one of the properties listed below.
methodName is one of the methods listed below.
Property of
描述
The history object is a linked list of URLs the user has visited, as shown in the Navigators Go menu.
Properties
Methods
Event handlers
例子
Example 1. The following example goes to the URL the user visited three clicks ago in the current window.
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:
Example 3. The following example causes the second frame in a frameset to go back one item:
Example 4. The following example causes the frame named frame1 in a frameset to go back one item:
Example 5. The following example causes the frame named frame2 in window2 to go back one item:
相关
host property
A string specifying the hostname:port portion of the URL.
语法
1. links[index].host2. 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.
相关
hostname property
A string specifying the host and domain name, or IP address, of a network host.
语法
1. links[index].hostname2. 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.
相关
href property
A string specifying the entire URL.
语法
1. links[index].href2. 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:
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_objectnewWindow.location.protocol = http:newWindow.location.host = home.netscape.comnewWindow.location.hostName = home.netscape.comnewWindow.location.port = newWindow.location.pathname = /comprod/products/navigator/version_2.0/script/ script_info/objects.htmnewWindow.location.search = newWindow.location.hash = #checkbox_object
相关
更多精彩
赞助商链接