Search code examples
javascripthtmlbrowser-history

How to avoid including a page in the browsing history


I have 2 JSPs: page1.jsp and page2.jsp.

the output of page1.jsp, under some circunstances, may be:

<a href="page2.jsp" id="hiddenlink" style="display:none;" >not displayed</a>
<script>this.location.href=document.getElementById("hiddenlink").href;</script>

The reason to do a redirection in this weird way is because there's a layer (a filter) in the webapp that rewrites all link's URLs into unreadable strings. The browser will get something like <a href="_YerwfwTWEf5YH34njtyRX"...>.

In these cases, is there a way (a meta or a header or whatever) to avoid page1.jsp being stored in the browser's history?

Thanks


Solution

  • The only way is to use location.replace via Javascript. Any other method (clicking links, redirects, etc...) will add new entries to the history.