How can I escape the #
hash sign (sometimes known as number sign or pound sign) sent in the query string of a URL?
1 Answer
Percent encoding. Replace the hash with %23
.
-
-
5This doesn't work on Chrome 74. Furthermore,
encodeURI('#');
is returning#
and not the percent encoded character May 20, 2019 at 12:10 -
28
#
is a valid URI character, but it starts the hash fragment, so you need to encode it in the query string. CompareencodeURIComponent('#')
. What do you see in Chrome 74? May 21, 2019 at 14:48 -
1You must also encode a
#
anywhere in adata:
URL, otherwise it will be treated as a fragment identifier. Dec 12, 2022 at 19:20