Search code examples
javascriptbrowserbrowser-history

Wiping browser history with javascript (or preventing URL from being recorded)


I have a client (domestic violence center) who wants to know if we can prevent their site from showing up in browser history, or wipe the users visit from their browser history when they exit the site.

I know once someone is on the site we can build it in ways that prevent new pages from loading like a normal page using location.replace for navigation, but that initial page visit when someone typed in http://example.org will still be in the history.

Is it possible on page load to prevent the page from being recorded in the history, or erase the record if it exists?

I have a bad feeling it can't, but if anyone will know it's all my smartypants friends on Stack Overflow.


Solution

  • Unfortunately this can't be done.

    For your clients scenario, my best advice would be that users are educated on how to remove their visit from their browser history, and how to use anonymous browsing/private mode/incognito mode in future visits.