Richard12511
Richard12511

Reputation: 25

Javascript Back Button Behavior

I have a site I'm building where one of my pages contains several tab-panes. Whenever the user clicks on one of these tab-panes it updates the browser's history and thus affects the browser's back button functionality in an undesirable way. I've searched around on this site, but everything I found was people wanting the browser to take the user back to the previous tab, which isn't what I want. I want the browser to take the user back to the previous page, not the previous tab on the same page, if that makes sense.

I assume there should be a simple way to do this, but I just can't find it. Seems like I'm kind of alone in this want of mine.

The site is built with aspx and visual studios mvc framework.

here is a small code sample.

<ul class="nav nav-tabs">
     <li class="active"><a href="#tab1">Tab1</a></li>
     <li><a href="#tab2">Tab2</a></li>
     <li><a href="#tab3">Tab3</a></li>
</ul>
<div class="tab-content">
     <div class="tab-pane active" id="tab1">
     </div>
     <div class="tab-pane" id="tab2">
     </div>
     <div class="tab-pane" id="tab3">
     </div>
</div>

Upvotes: 1

Views: 241

Answers (1)

HatSoft
HatSoft

Reputation: 11191

this is a know issue

you will need to use the javsacript method window.location.replace(url);

using window.location.replace() the current page will not be saved in session history

Upvotes: 1

Related Questions