This property yields the host value of the HREF value in an <A> tag if there is one and an empty string if not.
You can redefine the hostname by assigning a new value to this property.
Be careful not to assign a port number with the host name, otherwise your new URL may acquire two port numbers which makes it invalid.
<HTML> <HEAD> </HEAD> <BODY> <A NAME="EXAMPLE" HREF="http://www.mydomain.com:8080/folder/file.html#abcdef">Click here</A><BR> <SCRIPT> // In testing, this did not work in Opera 5.0 document.write(document.links[0].hostname); </SCRIPT> </BODY> </HTML>
See also: | Anchor.hash, Anchor.hostname, URL, Url object, Url.href, Url.pathname, Url.port, Url.protocol, Url.search, Url.target |
Prev | Home | Next |
Url.host | Up | Url.href |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |