Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Location port Property

Location port Property

Location Object Reference Location object


Definition and Usage

The port property is a readable and writable string that sets or returns the port part of the current URL.

**Note:** If the port number is 80 (which is the default port number), it does not need to be specified.

Syntax

location.port


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the port property.


Example

Example

Return the port number of the current URL:

The output of the above example is:

Try it »


Location Object Reference Location object