2

I am working on a client site where the client has requested that there be a button (basic a link) that links to another page like google, in case an abusive significant other busts into the room while a woman is reading about how to get assistance. The tricky part is that I am trying to figure out to link to a page that will open int he same windows, but no let you go back to the site by clicking the browser's back button, or show up in "history". I have built a lot of website and never heard of this being possible without the use of a custom browser extension or something.

My question is ..

Is there a way to do this? Possible some JS magic? Just wondering

Anton Balaniuc
  • 10,889
  • 1
  • 35
  • 53

2 Answers2

3

You're looking for location.replace().

<button onclick='location.replace("https://www.google.com");'>Click to close</button>

Instead of creating a new entry in browser history, it replaces the current one.

Note: Unfortunately, it's blocked by [SO]. But just try it in your app. It does work.

Second note: If you combine this with initially opening the to be hidden page in a new tab (target="_blank") => no history.


However, the best method and advice for such cases is browsing in incognito: Ctrl+Shift+N. Once closed, it's gone, with all history in the session. Pressing Ctrl+Shift+T in a new browser window won't bring the formerly opened tabs back.

IMHO, this technique should be clearly detailed in the "Precautions" section of your client's website, also advising on having another "normal" browsing session opened in a background browser window, with a few neutral tabs open on subjects that wouldn't raise any suspicions: cooking recipes, things for children, cosmetics, etc...

tao
  • 82,996
  • 16
  • 114
  • 150
  • I initially thought the same thing (referencing my crappy answer below). But thats actually a bad idea because if you visit more than one page it doesn't hide your history. So this is an incomplete solution for someone trying to hide that they were on a domestic violence site. But, CSS-tricks nailed it as usual. This is the best and most complete solution by far. I definitly learned something new on this one. https://css-tricks.com/examples/OpenCloseWindow/ – Rob Williams Sep 06 '17 at 22:22
  • Actually, you could build an app/website that uses `location.replace()` for navigation so that no matter how many pages you open, they always open in the same browser history entry. It's a considerable effort but, considering the customer needs, it's one of the multiple things that could be done. – tao Sep 06 '17 at 22:29
  • @Rob, I have some history in coding websites for people with special needs. In this case, nothing beats Ctrl+Shift+N in Chrome. That has to be thoroughly and clearly outlined in the section dedicated to "Precautions" of your client's website, IMHO. They also need to keep a regular browser with a few tabs open in the back, for best results, on subjects like recipes, stuff for kids, etc. – tao Sep 06 '17 at 22:33
  • This is a good point. I will work on implementing this before launch. I have been thinking that the site needs a disclaimer of some sort (as a fall back), so thanks for that idea as well. The initial idea came because not everyone is as savvy with a browser as you or I. So this was more of fallback without going the full app route. The page I linked to on CSS-Tricks has a good conversation on this in the comment thread. – Rob Williams Sep 12 '17 at 00:08
0

I am not sure about your question. But on click you can open Iframe

<iframe src="www.google.com" style="border:none;"></iframe>
Raj Parekh
  • 94
  • 1
  • 12