📄 ref_h-l.htm
字号:
<P>See <A HREF="tppmsgs/msgs0.htm#12" tppabs="http://www.cis.ohio-state.edu/htbin/rfc/rfc1738.htm" TARGET="_top">RFC 1738</A> for complete information about the URL.
<H3>例子</H3>
<P>In the following example, the <TT>window.open</TT> statement creates a window called <I>newWindow</I> and loads the specified URL into it. The <TT>document.write</TT> statements display all the properties of <TT>newWindow.location</TT> in a window called <I>msgWindow</I>.
<PRE>
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()
</PRE>
<P>The previous example displays output such as the following:
<PRE>
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
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_h-l.htm#hash_property" hash_property">hash</A>, <A HREF="ref_h-l.htm#host_property" host_property">host</A>, <A HREF="ref_h-l.htm#hostname_property" hostname_property">hostname</A>, <A HREF="ref_m-q.htm#pathname_property" pathname_property">pathname</A>, <A HREF="ref_m-q.htm#port_property" port_property">port</A>, <A HREF="ref_m-q.htm#protocol_property" protocol_property">protocol</A>, <A HREF="ref_s-s.htm#search_property" search_property">search</A> properties
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="index_property"><H2>index property</H2></A>
<P>
An integer representing the index of an option in a select object.
<H3>语法</H3>
<PRE>
<I>selectName</I>.options[<I>indexValue</I>].index
</PRE>
<P><I>selectName</I> is either the value of the NAME attribute of a select object or an element in the <I>elements</I> array.
<BR><I>indexValue</I> is an integer representing an option in a select object.
<H3>Property of</H3>
<P><A HREF="ref_s-s.htm#select_object" select_object">options</A> array
<H3>描述</H3>
<P>The number identifying the position of the option in the selection, starting from zero.
<H3>相关</H3>
<LI><A HREF="ref_d-e.htm#defaultSelected_property" defaultSelected_property">defaultSelected</A>, <A HREF="ref_s-s.htm#selected_property" selected_property">selected</A>, <A HREF="ref_s-s.htm#selectedIndex_property" selectedIndex_property">selectedIndex</A> properties
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="indexOf_method"><H2>indexOf method</H2></A>
<P>
Returns the index within the calling string object of the first occurrence of the specified value, starting the search at <I>fromIndex</I>.
<H3>语法</H3>
<PRE><I>stringName</I>.indexOf(<I>searchValue</I>, [<I>fromIndex</I>])</PRE>
<P><I>stringName</I> is any string or a property of an existing object.
<BR><I>searchValue</I> is a string or a property of an existing object, representing the value to search for.
<BR><I>fromIndex</I> is the location within the calling string to start the search from. It can be any integer from 0 to <I>stringName</I>.length - 1 or a property of an existing object.
<H3>Method of</H3>
<P><A HREF="ref_s-s.htm#string_object" string_object">string</A>
<H3>描述</H3>
<P>Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is <I>stringName</I>.length - 1.
<P>If you do not specify a value for <I>fromIndex</I>, JavaScript assumes 0 by default. If <I>searchValue</I> is not found, JavaScript returns -1.
<H3>例子</H3>
The following example uses indexOf and lastIndexOf to locate values in the string "Brave new world".
<PRE>
var anyString="Brave new world"
//Displays 8
document.write("<P>The index of the first w from the beginning is " +
anyString.indexOf("w"))
//Displays 10
document.write("<P>The index of the first w from the end is " +
anyString.lastIndexOf("w"))
//Displays 6
document.write("<P>The index of 'new' from the beginning is " +
anyString.indexOf("new"))
//Displays 6
document.write("<P>The index of 'new' from the end is " +
anyString.lastIndexOf("new"))
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#charAt_method" charAt_method">charAt</A>, <A HREF="ref_h-l.htm#lastIndexOf_method" lastIndexOf_method">lastIndexOf</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="isNaN_method"><H2>isNaN function</H2></A>
<P>
On Unix platforms, evaluates an argument to determine if it is "NaN" (not a number).
<H3>语法</H3>
<PRE>isNaN(<I>testValue</I>)</PRE>
<P><I>testValue</I> is the value you want to evaluate.
<H3>描述</H3>
<P>The isNaN function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself. isNaN is available on Unix platforms only.
<P>On all platforms except Windows, the parseFloat and parseInt functions return "NaN" when they evaluate a value that is not a number. The "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseFloat or parseInt is "NaN". If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN".
<P>The isNaN function returns true or false.
<H3>例子</H3>
<P>
The following example evaluates <I>floatValue</I> to determine if it is a number, then calls a procedure accordingly.
<PRE>
floatValue=parseFloat(toFloat)
if isNaN(floatValue) {
notFloat()
} else {
isFloat()
}
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_m-q.htm#parseFloat_method" parseFloat_method">parseFloat</A>, <A HREF="ref_m-q.htm#parseInt_method" parseInt_method">parseInt</A> functions
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="italics_method"><H2>italics method</H2></A>
<P>
Causes a string to be italicized as if it were in an <I> tag.
<H3>语法</H3>
<PRE><I>stringName</I>.italics()</PRE>
<P><I>stringName</I> is any string or a property of an existing object.
<H3>Method of</H3>
<P><A HREF="ref_s-s.htm#string_object" string_object">string</A>
<H3>描述</H3>
<P>Use the italics method with the write or writeln methods to format and display a string in a document.
<H3>例子</H3>
The following example uses string methods to change the formatting of a string:
<PRE>
var worldString="Hello, world"
document.write(worldString.blink())
document.write("<P>" + worldString.bold())
document.write("<P>" + worldString.italics())
document.write("<P>" + worldString.strike())
</PRE>
<P>The previous example produces the same output as the following htm:
<PRE>
<TT><BLINK>Hello, world</BLINK></TT>
<TT><P><B>Hello, world</B></TT>
<TT><P><I>Hello, world</I></TT>
<TT><P><STRIKE>Hello, world</STRIKE></TT>
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#blink_method" blink_method">blink</A>, <A HREF="ref_a-c.htm#bold_method" bold_method">bold</A>, <A HREF="ref_s-s.htm#strike_method" strike_method">strike</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="lastIndexOf_method"><H2>lastIndexOf method</H2></A>
<P>
Returns the index within the calling string object of the last occurrence of the specified value. The calling string is searched backwards, starting at <I>fromIndex</I>.
<H3>语法</H3>
<PRE><I>stringName</I>.lastIndexOf(<I>searchValue</I>, [<I>fromIndex</I>])</PRE>
<P><I>stringName</I> is any string or a property of an existing object.
<BR><I>searchValue</I> is a string or a property of an existing object, representing the value to search for.
<BR><I>fromIndex</I> is the location within the calling string to start the search from. It can be any integer from 0 to <I>stringName</I>.length - 1 or a property of an existing object.
<H3>Method of</H3>
<P><A HREF="ref_s-s.htm#string_object" string_object">string</A>
<H3>描述</H3>
<P>Characters in a string are indexed from left to right. The index of the first character is 0, and the index of the last character is <I>stringName</I>.length - 1.
<P>If you do not specify a value for <I>fromIndex</I>, JavaScript assumes <I>stringName</I>.length - 1 (the end of the string) by default. If <I>searchValue</I> is not found, JavaScript returns -1.
<H3>例子</H3>
The following example uses indexOf and lastIndexOf to locate values in the string "Brave new world".
<PRE>
var anyString="Brave new world"
//Displays 8
document.write("<P>The index of the first w from the beginning is " +
anyString.indexOf("w"))
//Displays 10
document.write("<P>The index of the first w from the end is " +
anyString.lastIndexOf("w"))
//Displays 6
document.write("<P>The index of 'new' from the beginning is " +
anyString.indexOf("new"))
//Displays 6
document.write("<P>The index of 'new' from the end is " +
anyString.lastIndexOf("new"))
</PRE>
<H3>相关</H3>
<LI><A HREF="ref_a-c.htm#charAt_method" charAt_method">charAt</A>, <A HREF="ref_h-l.htm#indexOf_method" indexOf_method">indexOf</A> methods
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="lastModified_property"><H2>lastModified property</H2></A>
<P>
A string representing the date that a document was last modified.
<H3>语法</H3>
<PRE>document.lastModified</PRE>
<H3>Property of</H3>
<P><A HREF="ref_d-e.htm#document_object" document_object">document</A>
<H3>描述</H3>
<P>lastModified is a read-only property.
<H3>例子</H3>
<P>In the following example, the lastModified property is used in a <SCRIPT> tag at the end of an htm file to display the modification date of the page:
<PRE>
document.write("This page updated on " + document.lastModified)
</PRE>
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="length_property"><H2>length property</H2></A>
<P>
An integer that specifies a length-related feature of the calling object or array.
<H3>语法</H3>
<P>When used with objects:
<PRE>
1. <I>formName</I>.length
2. <I>frameReference</I>.length
3. history.length
4. <I>radioName</I>.length
5. <I>selectName</I>.length
6. <I>stringName</I>.length
7. <I>windowReference</I>.length
</PRE>
<P>When used with array properties:
<PRE>
8. anchors.length
9. elements.length
10. forms.length
11. <I>frameReference</I>.frames.length
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -