miguel perher
miguel perher

Reputation: 901

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

Upvotes: 1

Views: 3683

Answers (2)

jfriend00
jfriend00

Reputation: 707456

Instead of this:

this.location.href=document.getElementById("hiddenlink").href;

Use this to replace the current page in the browser history so only page2.jsp will be in the history:

window.location.replace(document.getElementById("hiddenlink").href);

Upvotes: 1

Marc B
Marc B

Reputation: 360702

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

Upvotes: 2

Related Questions