• Web APIs
  • Location interface is a string containing the port number of the location's URL. If the port is the default for the protocol (80 for ws: and http:, 443 for wss: and https:, and 21 for ftp:), this property contains an empty string, "".

    This property can be set to change the port of the URL. If the URL has no host or its scheme is file:, then setting this property has no effect. It also silently ignores invalid port numbers.

    See

    / Assume another page is at https://developer.mozilla.org:8888/en-US/docs/Location/port
    const result = location.port; / Returns:'8888'
    
  • Specifications

    Specification
    Product help
  • href
  • protocol
  • replace()
  • toString()
  • ","source":{"folder":"en-us/web/api/location/port","github_url":"https://github.com/mdn/content/blob/main/files/en-us/web/api/location/port/index.md","last_commit_url":"https://github.com/mdn/content/commit/8cc63f7e6619446ea38f6a38c457a597a9af564b","filename":"index.md"},"summary":"The port property of the Location interface is a string containing the port number of the location's URL. If the port is the default for the protocol (80 for ws: and http:, 443 for wss: and https:, and 21 for ftp:), this property contains an empty string, \"\".","title":"Location: port property","toc":[{"text":"Value","id":"value"},{"text":"Examples","id":"examples"},{"text":"Specifications","id":"specifications"},{"text":"Browser compatibility","id":"browser_compatibility"}],"baseline":{"baseline":"high","baseline_low_date":"2015-07-29","baseline_high_date":"2018-01-29","support":{"chrome":"1","chrome_android":"18","edge":"12","firefox":"1","firefox_android":"4","safari":"1","safari_ios":"1"}},"browserCompat":["api.Location.port"],"pageType":"web-api-instance-property"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant