Location port Property
Return the port number of the current URL:
The result of x will be (If the port number is 80, which is default, nothing will be returned):
Try it yourself »
Definition and Usage
The port property sets or returns the port number the server uses for a URL.
Note: If the port number is 80 (which is the default port number), nothing will be returned.
The port property is supported in all major browsers.
Return the port property:
Set the port property:
|port||String||Specifies the port number of the URL|
|String||The port number of a URL.
Note: If the port number is 80 (which is the default port number), an empty string is returned
Thank You For Helping Us!
Your message has been sent to W3Schools.