• Web APIs
  • Location interface is a string containing the path of the URL for the location. If there is no path, pathname will be empty: otherwise, pathname contains an initial '/' followed by the path of the URL, not including the query string or fragment.

  • Value

    A string.

    Examples

    js
    / Let's say we are on the URL https://developer.mozilla.org/en-US/docs/Web/API/Location/pathname#examples
    console.log(location.pathname); / '/en-US/docs/Web/API/Location/pathname'
    

    Specifications

    Specification
    Product help
  • host
  • pathname
  • assign()
  • toString()
  • ","source":{"folder":"en-us/web/api/location/pathname","github_url":"https://github.com/mdn/content/blob/main/files/en-us/web/api/location/pathname/index.md","last_commit_url":"https://github.com/mdn/content/commit/1238ffad886924b20549d0cf3adca735cb0d074f","filename":"index.md"},"summary":"The pathname property of the Location\ninterface is a string containing the path of the URL for the location. If there is no path, pathname will be empty: otherwise, pathname contains an initial '/' followed by the path of the URL, not including the query string or fragment.","title":"Location: pathname 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.pathname"],"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