Location: port-Eigenschaft
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since Juli 2015.
Die port-Eigenschaft des Location-Interfaces ist ein String, der die Portnummer der URL des Standorts enthält. Wenn der Port der Standardport für das Protokoll ist (80 für ws: und http:, 443 für wss: und https:, und 21 für ftp:), enthält diese Eigenschaft einen leeren String, "".
Diese Eigenschaft kann festgelegt werden, um den Port der URL zu ändern. Wenn die URL keinen host hat oder das Schema file: ist, hat das Festlegen dieser Eigenschaft keine Wirkung. Ungültige Portnummern werden ebenfalls stillschweigend ignoriert.
Weiterführende Informationen finden Sie unter URL.port.
Wert
Ein String.
Beispiele
// Assume current page is at https://developer.mozilla.org/en-US/docs/Location/port
const result = location.port; // Returns:''
// Assume another page is at https://developer.mozilla.org:8888/en-US/docs/Location/port
const result = location.port; // Returns:'8888'
Spezifikationen
| Specification |
|---|
| HTML> # dom-location-port-dev> |
Browser-Kompatibilität
Loading…