Location interface is a search string, also called a query string, that is a string containing a "?" followed by the parameters of the location's URL. If the URL does not have a search query, this property contains an empty string, "".
This property can be set to change the query string of the URL. When setting, a single "?" prefix is added to the provided value, if not already present. Setting it to "" removes the query string.
The query is percent-encoded when setting but not percent-decoded when reading.
Modern browsers provide
URLSearchParams
and
URL.searchParams
to make it easy to parse out the parameters from the querystring.
","source":{"folder":"en-us/web/api/location/search","github_url":"https://github.com/mdn/content/blob/main/files/en-us/web/api/location/search/index.md","last_commit_url":"https://github.com/mdn/content/commit/8cc63f7e6619446ea38f6a38c457a597a9af564b","filename":"index.md"},"summary":"The search property of the Location interface is a search string, also called a query string, that is a string containing a \"?\" followed by the parameters of the location's URL. If the URL does not have a search query, this property contains an empty string, \"\".","title":"Location: search 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.search"],"pageType":"web-api-instance-property"}}