3

I'm creating a website for people who need help (getting abused and stuff). There is an 'escape' button on the site to switch to another site if someone wants to hide what they were looking for. But the visited page is still in the history of the browser.

Is there any way to make the site remove itself from browser history? Or does the user need to activate 'incognito' ?

Cryothic
  • 771
  • 7
  • 18
  • Does this answer your question? [How to clear browsers (IE, Firefox, Opera, Chrome) history using JavaScript or Java except from browser itself?](https://stackoverflow.com/questions/2190808/how-to-clear-browsers-ie-firefox-opera-chrome-history-using-javascript-or-j) – Xantium Mar 23 '20 at 10:55

3 Answers3

1

location.replace SHOULD have done this

The Location.replace() method replaces the current resource with the one at the provided URL. The difference from the assign() method is that after using replace() the current page will not be saved in session History, meaning the user won't be able to use the back button to navigate to it.

try

This test

<button type="button" onclick="location.replace('https://safe.site.com')">Leave</button>

which will replace CURRENT page - so your site needs to be a single page application (SPA) OR every click on the page needs to do location replace too

But yes, suggest incognito

mplungjan
  • 169,008
  • 28
  • 173
  • 236
0

There is no way of doing this. You have no control over browser history.

It's possible (under Firefox anyway) to delete history using history.deleteAll() but that requires an extension to be added (documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/history/deleteAll). Which probably doesn't help.

Xantium
  • 11,201
  • 10
  • 62
  • 89
0

It's not possible to clear user history without plugins.

For information refer to How to clear browsers (IE, Firefox, Opera, Chrome) history using JavaScript or Java except from browser itself?