How can I replace a window’s URL hash with another response?
Either use location or window.location instead of document.location as the latter is a non-standard. window.location.hash=”#food”; This will replace the URL’s hash with the value you set for it. Reference