javascript手冊-l
javascript手冊-l Choose a destination from the following list, then click "Click me" below.
Netscape home page
Sun home page
RFC 1867 Click meExample 5: links array. The following example opens the Netscape home page in the newWindow window. The linkGetter() function uses the links array to display the value of each of its links. newWindow=window.open("http://www.netscape.com")function linkGetter() { msgWindow=window.open("") for (var i = 0; i
") }}相关anchor object link method linkColor propertyA string specifying the color of the document hyperlinks. 语法document.linkColor
Property ofdocument 描述The linkColor property is expressed as a hexadecimal RGB triplet or as one of the string literals listed in Color Values. This property is the JavaScript reflection of the LINK attribute of the <BODY> tag. The default value of this property is set by the user on the Colors tab of the Preferences dialog box, which is displayed by choosing General Preferences from the Options menu. You cannot set this property after the htm source has been through layout. If you express the color as a hexadecimal RGB triplet, you must use the format rrggbb. For example, the hexadecimal RGB values for salmon are red=FA, green=80, and blue=72, so the RGB triplet for salmon is "FA8072". 例子The following example sets the color of document links to aqua using a string literal: document.linkColor="aqua"
The following example sets the color of document links to aqua using a hexadecimal triplet: document.linkColor="00FFFF"
相关alinkColor, bgColor, fgColor, and vlinkColor properties links propertyAn array of objects corresponding to link objects in source order. See link object. LN2 propertyThe natural logarithm of two, approximately 0.693. 语法Math.LN2
Property ofMath 描述Because LN2 is a constant, it is a read-only property of Math. 例子The following example displays the natural log of 2: document.write("The natural log of 2 is " + Math.LN2)
相关E, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties LN10 propertyThe natural logarithm of ten, approximately 2.302. 语法Math.LN10
Property ofMath 描述Because LN10 is a constant, it is a read-only property of Math. 例子The following example displays the natural log of 10: document.write("The natural log of 10 is " + Math.LN10)
相关E, LN2, LOG2E, LOG10E, PI, SQRT1_2, SQRT2 properties location objectContains information on the current URL. 语法To use a location object: [windowReference.]location[.propertyName]
windowReference is a variable windowVar from a window definition (see window object), or one of the synonyms top or parent.
propertyName is one of the properties listed below. Omitting the property name is equivalent to specifying the href property (the complete URL). Property ofwindow 描述The location object represents a complete URL. Each property of the location object represents a different portion of the URL. The following diagram of a URL shows the relationships between the location properties: protocol//hostname:port pathname search hash
protocol represents the beginning of the URL, up to and including the first colon.
hostname represents the host and domain name, or IP address, of a network host.
port represents the communications port that the server uses for communications.
pathname represents the url-path portion of the URL.
search represents any query information in the URL, beginning with a question mark.
hash represents an anchor name fragment in the URL, beginning with a hash mark (#). See the properties (listed below) for details about the different parts of the URL, or the href property for 例子. The location object has two other properties not shown in the diagram above: href represents a complete URL.
host represents the concatenation hostname:port. 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, windowReference.location.propertyName, the location object represents the location of the specified window. Do not confuse the location object with the location property of the document object. You cannot change the value of the location property (document.location), but you can change the value of the location object's properties (window.location.propertyName). document.location is a string-valued property that usually matches what window.location.href is set to when you load the document, but redirection may change it. 语法 for common URL typesWhen 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. URL typeProtocolExampleJavaScript code
javascript:
javascript:history.go(-1)
Navigator info
about:
about:cache
World Wide Web
http:
http://www.netscape.com/
File
file:
file:///javascript/methods.htm
FTP
ftp:
ftp://ftp.mine.com/home/mine
MailTo
mailto:
mailto:info@netscape.com
Usenet
news:
news://news.scruznet.com/comp.lang.javascript
Gopher
gopher:
gopher.myhost.com
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. The about: protocol provides information on Navigator and has the following 语法: about:[cache|plugins]
about: by itself is the same as choosing About Netscape from the Navigator's Help menu.
about:cache displays disk cache statistics.
about:plug-ins displays information about plug-ins you have configured. This is the same as choosing About Plug-ins from the Navigator's Help menu. Propertieshash specifies an anchor name in the URL host specifies the hostname:port portion of the URL hostname specifies the host and domain name, or IP address, of a network host href specifies the entire URL pathname specifies the url-path portion of the URL port specifies the communications port that the server uses for communications protocol specifies the beginning of the URL, including the colon search specifies a query MethodsNone. Event handlersNone. 例子Example 1. 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/"Example 2. The following statement sets the URL of a frame named frame2 to the Sun home page: parent.frame2.location.href="http://www.sun.com/"相关 the example for the anchor object. 相关history object location property location propertyA string specifying the complete URL of the document. 语法document.location
Property ofdocument 描述Do not confuse the location property of the document object with the location object. You cannot change the value of the location property (document.location), but you can change the value of the location object's properties (window.location.propertyName). document.location is a string-valued property that usually matches what window.location.href is set to when you load the document, but redirection may change it. location is a read-only property of document. 例子The following example displays the URL of the current document: document.write("The current URL is " + document.location)
相关location object log methodReturns the natural logarithm (base e) of a number. 语法Math.log(number)
number is any positive numeric expression or a property of an existing object. Method ofMath 描述If the value of number is outside the suggested range, the return value is always -1.797693134862316e+308. 例子//Displays the value 2.302585092994046document.write("The natural log of 10 is " + Math.log(10))//Displays the value 0document.write("<P>The natural log of 1 is " + Math.log(1))//Displays the value -1.797693134862316e+308//because the argument is out of rangedocument.write("<P>The natural log of 0 is " + Math.log(0))
相关exp, pow methods LOG2E propertyThe base 2 logarithm of e (approximately 1.442). 语法Math.LOG2E
Property ofMath 描述Because LOG2E is a constant, it is a read-only property of Math. 例子The following example displays the base 2 logarithm of E: document.write("The base 2 logarithm of E is " + Math.LOG2E)
相关E, LN2, LN10, LOG10E, PI, SQRT1_2, SQRT2 properties LOG10E propertyThe base 10 logarithm of e (approximately 0.434). 语法Math.LOG10E
Property ofMath 描述Because LOG10E is a constant, it is a read-only property of Math. 例子The following example displays the base 10 logarithm of E: document.write("The base 10 logarithm of E is " + Math.LOG10E)
相关E, LN2, LN10, LOG2E, PI, SQRT1_2, SQRT2 properties