0

Hi I'm wondering if there is a way to give window.history.go(-1) a default back page? If you enter a page directly from another site and someone clicks the back button, I don't want to direct them back to the referring site, I'd rather redirect them back to a search page within my application. I notice on some sites they are somehow reading the previous session, is that an option or no? Thanks

Code Junkie
  • 7,602
  • 26
  • 79
  • 141

2 Answers2

1

may be try something like this:

<a href="www.google.com" onclick="window.history.go(-1); return false;"> Back </a>
Suchit kumar
  • 11,809
  • 3
  • 22
  • 44
0

I think you might be interested in the window onbeforeunload event.

Have a look at this thread: using onbeforeunload event, url change on selecting stay on this page

Community
  • 1
  • 1
jennas
  • 2,444
  • 2
  • 25
  • 31
  • Beware to use window onbeforeunload event, because most mobile browsers don't support this event. Instead use History API. [this](http://stackoverflow.com/questions/6205989/is-there-an-alternative-method-to-use-onbeforeunload-in-mobile-safari) will help. – Domain Nov 13 '14 at 06:57