X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Anchor port Property

Anchor Object Reference Anchor Object

Example

Return the port number of a link:

var x = document.getElementById("myAnchor").port;

The result of x could be:

4097

Try it yourself »


Definition and Usage

The port property sets or returns the port part of the href attribute value.

Note: If the port number is not specified in the URL (or if it is the scheme's default port - like 80, or 443), some browsers will display 0 or nothing.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The port property is supported in all major browsers.


Syntax

Return the port property:

anchorObject.port

Set the port property:

anchorObject.port=number

Property Values

Value Description
number Specifies the port number of a URL

Technical Details

Return Value: A String, representing the port number of the URL


More Examples

Example

Change the port number of a link:

document.getElementById("myAnchor").port = "80";

Try it yourself »

Related Pages

JavaScript reference: location.port Property


Anchor Object Reference Anchor Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook