Sets or retrieves the port number associated with a URL.
Syntax
HTML | N/A |
---|
Scripting | [ sPort = ] object.port |
---|
Possible Values
sPort | String that
specifies or receives the port number associated with the URL. See remarks. |
The property is read/write.
The property has no default value.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see About Dynamic Properties.
Remarks
The port will resolve based on the default port for the protocol set in the HREF attribute: 21
for FTP, 80
for HTTP, and so forth.
Proprietary protocols that do not require a port return 0
or an empty string.
location.port returns an empty string when read in a page reached by the http protocol.
Example
This example function returns the port property of two a elements.
<SCRIPT>
function getPort()
{
alert ("FTP: " + oFtp.port + "\n" + "HTTP: " + oHttp.port);
}
</SCRIPT>
<A HREF="ftp://www.microsoft.com" ID=oFtp>ftp</A>
<A HREF="http://www.microsoft.com" ID=oHttp>http</A>
Standards Information
There is no public standard that applies to this property.
Applies To