Windowlocationhash
Windowlocationhash refers to the fragment portion of the current document URL, accessible in JavaScript as window.location.hash. The fragment, known as the hash, starts with a leading # and is used for in-page anchors or as a client-side routing mechanism in single-page applications. The value of location.hash includes the leading #, for example #section.
Reading and writing are straightforward. To read the current hash, access window.location.hash. To set it, assign
Changing the hash does not cause a full page reload in most cases. Instead, browsers typically scroll
Events are used to react to hash changes. The hashchange event fires on the window object whenever
Common uses include in-page navigation to specific sections, maintaining UI state in single-page applications, and enabling