简体   繁体   中英

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM