Anchor port attribute

Definition and usage

port Attribute setting or return href attribute value The port part.

Note:If the port number is not specified in the URL (or if it is the default port of the protocol - for example, 80 or 443), some browsers will display 0 or not display.

See also:

JavaScript Reference Manual:location.port attribute

Example

Example 1

Return the port number of the link:

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

Try it yourself

Example 2

Change the port number of the link:

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

Try it yourself

Syntax

Return port attribute:

anchorObject.port

Indstil port egenskab:

anchorObject.port = number

Egenskabsværdi

Værdi Beskrivelse
number Definerer URL's portnummer.

Tekniske detaljer

Returværdi: Strengværdi, der repræsenterer URL's portnummer.

Browser understøttelse

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support