⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ref_h-l.htm

📁 javascript函数大全HTML javascript函数大全HTML
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<P><A HREF="ref_m-q.htm#Math_object" Math_object">Math</A>

<H3>描述</H3>
<P>Because LN2 is a constant, it is a read-only property of Math.

<H3>例子</H3>
<P>The following example displays the natural log of 2:
<PRE>document.write("The natural log of 2 is " + Math.LN2)</PRE>

<H3>相关</H3>
<LI><A HREF="ref_d-e.htm#E_property" E_property">E</A>, <A HREF="ref_h-l.htm#LN10_property" LN10_property">LN10</A>, <A HREF="ref_h-l.htm#LOG2E_property" LOG2E_property">LOG2E</A>, <A HREF="ref_h-l.htm#LOG10E_property" LOG10E_property">LOG10E</A>, <A HREF="ref_m-q.htm#PI_property" PI_property">PI</A>, <A HREF="ref_s-s.htm#SQRT1_2_property" SQRT1_2_property">SQRT1_2</A>, <A HREF="ref_s-s.htm#SQRT2_property" SQRT2_property">SQRT2</A> properties
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="LN10_property"><H2>LN10 property</H2></A>
<P>
The natural logarithm of ten, approximately 2.302.

<H3>语法</H3>
<PRE>Math.LN10</PRE>

<H3>Property of</H3>
<P><A HREF="ref_m-q.htm#Math_object" Math_object">Math</A>

<H3>描述</H3>
<P>Because LN10 is a constant, it is a read-only property of Math.

<H3>例子</H3>
<P>The following example displays the natural log of 10:
<PRE>document.write("The natural log of 10 is " + Math.LN10)</PRE>

<H3>相关</H3>
<LI><A HREF="ref_d-e.htm#E_property" E_property">E</A>, <A HREF="ref_h-l.htm#LN2_property" LN2_property">LN2</A>, <A HREF="ref_h-l.htm#LOG2E_property" LOG2E_property">LOG2E</A>, <A HREF="ref_h-l.htm#LOG10E_property" LOG10E_property">LOG10E</A>, <A HREF="ref_m-q.htm#PI_property" PI_property">PI</A>, <A HREF="ref_s-s.htm#SQRT1_2_property" SQRT1_2_property">SQRT1_2</A>, <A HREF="ref_s-s.htm#SQRT2_property" SQRT2_property">SQRT2</A> properties
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="location_object"><H2>location object</H2> </A>
<P>Contains information on the current URL.


<H3>语法</H3>
<P>To use a location object:
<PRE>
[<I>windowReference</I>.]location[.<I>propertyName</I>]
</PRE>
<I>windowReference</I> is a variable <I>windowVar</I> from a window definition (see <A HREF="ref_t-z.htm#window_object" window_object">window</A> object), or one of the synonyms top or parent.
<BR><I>propertyName</I> is one of the properties listed below. Omitting the property name is equivalent to specifying the href property (the complete URL).


<H3>Property of</H3>
<LI><A HREF="ref_t-z.htm#window_object" window_object">window</A>


<H3>描述</H3>
<P>The location object represents a complete URL. Each property of the location object represents a different portion of the URL.

<P>The following diagram of a URL shows the relationships between the location properties:

<PRE><I>protocol</I>//<I>hostname</I>:<I>port</I> <I>pathname</I> <I>search</I> <I>hash</I></PRE>
<P><I>protocol</I> represents the beginning of the URL, up to and including the first colon.
<BR><I>hostname</I> represents the host and domain name, or IP address, of a network host.
<BR><I>port</I> represents the communications port that the server uses for communications.
<BR><I>pathname</I> represents the url-path portion of the URL.
<BR><I>search</I> represents any query information in the URL, beginning with a question mark.
<BR><I>hash</I> represents an anchor name fragment in the URL, beginning with a hash mark (#).

<P>See the properties (listed below) for details about the different parts of the URL, or the <A HREF="ref_h-l.htm#href_property" href_property">href</A> property for 例子.

<P>The location object has two other properties not shown in the diagram above:
<P><I>href</I> represents a complete URL.
<BR><I>host</I> represents the concatenation <I>hostname</I>:<I>port</I>.

<P>The location object is contained by the window object and is within its scope. If you reference a location object without specifying a window, the location object represents the current location. If you reference a location object and specify a window name, for example, <TT><I>windowReference</I>.location.<I>propertyName</I></TT>, the location object represents the location of the specified window.

<P>Do not confuse the location object with the location property of the document object. You cannot change the value of the location property (<TT>document.location</TT>), but you can change the value of the location object's properties (<TT>window.location.<I>propertyName</I></TT>). <TT>document.location</TT> is a string-valued property that usually matches what <TT>window.location.href</TT> is set to when you load the document, but redirection may change it.

<H3>语法 for common URL types</H3>
<P>When you specify a URL, you can use standard URL formats and JavaScript statements. The following list shows the 语法 for specifying some of the most common types of URLs.
<TABLE WIDTH=100% CELLSPACING=1>
<TR ALIGN=LEFT VALIGN=TOP>
<TH>URL&nbsptype</TH><TH>Protocol</TH><TH>Example</TH>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>JavaScript&nbspcode</TD><TD>javascript:</TD><TD>javascript:history.go(-1)</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>Navigator&nbspinfo</TD><TD>about:</TD><TD>about:cache</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>World&nbspWide&nbspWeb</TD><TD>http:</TD><TD>http://www.netscape.com/</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>File</TD><TD>file:</TD><TD>file:///javascript/methods.htm</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>FTP</TD><TD>ftp:</TD><TD>ftp://ftp.mine.com/home/mine</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>MailTo</TD><TD>mailto:</TD><TD>mailto:info@netscape.com</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>Usenet</TD><TD>news:</TD><TD>news://news.scruznet.com/comp.lang.javascript</TD>
</TR>
<TR ALIGN=LEFT VALIGN=TOP>
<TD>Gopher</TD><TD>gopher:</TD><TD>gopher.myhost.com</TD>
</TR>
</TABLE>

<P>The javascript: protocol evaluates the expression after the colon (:), if there is one, and loads a page containing the string value of the expression, unless it is undefined. If the expression evaluates to undefined, no new page loads.

<P>The about: protocol provides information on Navigator and has the following 语法:
<PRE>
about:[cache|plugins]
</PRE>
<I>about:</I> by itself is the same as choosing About Netscape from the Navigator's Help menu.
<BR><I>about:cache</I> displays disk cache statistics.
<BR><I>about:plug-ins</I> displays information about plug-ins you have configured. This is the same as choosing About Plug-ins from the Navigator's Help menu.


<H3>Properties</H3>
<LI><A HREF="ref_h-l.htm#hash_property" hash_property">hash</A> specifies an anchor name in the URL
<LI><A HREF="ref_h-l.htm#host_property" host_property">host</A> specifies the hostname:port portion of the URL
<LI><A HREF="ref_h-l.htm#hostname_property" hostname_property">hostname</A> specifies the host and domain name, or IP address, of a network host
<LI><A HREF="ref_h-l.htm#href_property" href_property">href</A> specifies the entire URL
<LI><A HREF="ref_m-q.htm#pathname_property" pathname_property">pathname</A> specifies the url-path portion of the URL
<LI><A HREF="ref_m-q.htm#port_property" port_property">port</A> specifies the communications port that the server uses for communications
<LI><A HREF="ref_m-q.htm#protocol_property" protocol_property">protocol</A> specifies the beginning of the URL, including the colon
<LI><A HREF="ref_s-s.htm#search_property" search_property">search</A> specifies a query


<H3>Methods</H3>
<LI>None.


<H3>Event handlers</H3>
<LI>None.


<H3>例子</H3>
<P><B>Example 1.</B> The following two statements are equivalent and set the URL of the current window to the Netscape home page:
<XMP>
window.location.href="http://www.netscape.com/"
window.location="http://www.netscape.com/"
</XMP>

<P><B>Example 2.</B> The following statement sets the URL of a frame named <I>frame2</I> to the Sun home page:
<XMP>
parent.frame2.location.href="http://www.sun.com/"
</XMP>

<P>相关 the example for the <A HREF="ref_a-c.htm#anchor_object" anchor_object">anchor</A> object.

<H3>相关</H3>
<LI><A HREF="ref_h-l.htm#history_object" history_object">history</A> object
<LI><A HREF="ref_h-l.htm#location_property" location_property">location</A> property

<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="location_property"><H2>location property</H2></A>
<P>
A string specifying the complete URL of the document.

<H3>语法</H3>
<PRE>document.location</PRE>

<H3>Property of</H3>
<P><A HREF="ref_d-e.htm#document_object" document_object">document</A>

<H3>描述</H3>
<P>Do not confuse the location property of the document object with the location object. You cannot change the value of the location property (<TT>document.location</TT>), but you can change the value of the location object's properties (<TT>window.location.<I>propertyName</I></TT>). <TT>document.location</TT> is a string-valued property that usually matches what <TT>window.location.href</TT> is set to when you load the document, but redirection may change it.

<P>location is a read-only property of document.

<H3>例子</H3>
<P>The following example displays the URL of the current document:
<PRE>
document.write("The current URL is " + document.location)
</PRE>

<H3>相关</H3>
<LI><A HREF="ref_h-l.htm#location_object" location_object">location</A> object
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="log_method"><H2>log method</H2></A>
<P>
Returns the natural logarithm (base <I>e</I>) of a number.

<H3>语法</H3>
<PRE>Math.log(<I>number</I>)</PRE>
<I>number</I> is any positive numeric expression or a property of an existing object.

<H3>Method of</H3>
<P><A HREF="ref_m-q.htm#Math_object" Math_object">Math</A>

<H3>描述</H3>
<P>If the value of <I>number</I> is outside the suggested range, the return value is always -1.797693134862316e+308.

<H3>例子</H3>
<PRE>
//Displays the value 2.302585092994046
document.write("The natural log of 10 is " + Math.log(10))

//Displays the value 0
document.write("&ltP&gtThe natural log of 1 is " + Math.log(1))

//Displays the value -1.797693134862316e+308
//because the argument is out of range
document.write("&ltP&gtThe natural log of 0 is " + Math.log(0))
</PRE>

<H3>相关</H3>
<LI><A HREF="ref_d-e.htm#exp_method" exp_method">exp</A>, <A HREF="ref_m-q.htm#pow_method" pow_method">pow</A> methods
<!------------------------------------------------------------------------------------------------->
<HR>
<A NAME="LOG2E_property"><H2>LOG2E property</H2></A>
<P>
The base 2 logarithm of e (approximately 1.442).

<H3>语法</H3>
<PRE>Math.LOG2E</PRE>

<H3>Property of</H3>
<P><A HREF="ref_m-q.htm#Math_object" Math_object">Math</A>

<H3>描述</H3>
<P>Because LOG2E is a constant, it is a read-only property of Math.

<H3>例子</H3>
<P>The following example displays the base 2 logarithm of E:
<PRE>document.write("The base 2 logarithm of E is " + Math.LOG2E)</PRE>

<H3>相关</H3>
<LI><A HREF="ref_d-e.htm#E_property" E_property">E</A>, <A HREF="ref_h-l.htm#LN2_property" LN2_property">LN2</A>, <A HREF="ref_h-l.htm#LN10_property" LN10_property">LN10</A>, <A HREF="ref_h-l.htm#LOG10E_property" LOG10E_property">LOG10E</A>,  <A HREF="ref_m-q.htm#PI_property" PI_property">PI</A>, <A HREF="ref_s-s.htm#SQRT1_2_property" SQRT1_2_property">SQRT1_2</A>, <A HREF="ref_s-s.htm#SQRT2_property" SQRT2_property">SQRT2</A> properties
<!------------------------------------------------------------------------------------------------>
<HR>
<A NAME="LOG10E_property"><H2>LOG10E property</H2></A>
<P>
The base 10 logarithm of e (approximately 0.434).

<H3>语法</H3>
<PRE>Math.LOG10E</PRE>

<H3>Property of</H3>
<P><A HREF="ref_m-q.htm#Math_object" Math_object">Math</A>

<H3>描述</H3>
<P>Because LOG10E is a constant, it is a read-only property of Math.

<H3>例子</H3>
<P>The following example displays the base 10 logarithm of E:
<PRE>document.write("The base 10 logarithm of E is " + Math.LOG10E)</PRE>

<H3>相关</H3>
<LI><A HREF="ref_d-e.htm#E_property" E_property">E</A>, <A HREF="ref_h-l.htm#LN2_property" LN2_property">LN2</A>, <A HREF="ref_h-l.htm#LN10_property" LN10_property">LN10</A>, <A HREF="ref_h-l.htm#LOG2E_property" LOG2E_property">LOG2E</A>, <A HREF="ref_m-q.htm#PI_property" PI_property">PI</A>, <A HREF="ref_s-s.htm#SQRT1_2_property" SQRT1_2_property">SQRT1_2</A>, <A HREF="ref_s-s.htm#SQRT2_property" SQRT2_property">SQRT2</A> properties
<!------------------------------------------------------------------------------------------------->
<HR>

<SCRIPT>
document.write("<FONT SIZE=-2>Last modified " + document.lastModified)
</SCRIPT>
<P>
</BODY>
<htm>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -