Bootstrap 2.3.2Abilita Indietro Manipolazione Pulsante con Twitter Bootstrap Tabs in IE8 +
Sto usando tabs da Bootstrap nel mio progetto per visualizzare il contenuto. Su una singola pagina ci sono più schede con contenuti diversi e in quelle schede ci sono collegamenti che portano l'utente ad altre pagine del sito web.
Purtroppo per impostazione predefinita, le schede non supportano indietro tasto di navigazione, quindi se un utente visita un'altra pagina e colpisce il pulsante Indietro del browser, la scheda avrà ripristinato la prima scheda aperta, piuttosto che quello che è stato attivo quando hanno visto l'ultima volta la pagina.
Il javascript riportato di seguito da François Zaninotto risolve questo problema in Chrome, Firefox e Safari. François dice anche che funziona per IE8 + - ma durante i miei test non riesco a farlo funzionare su IE8, IE9 o IE10. Qualcuno sa come farlo funzionare in IE8 +? È possibile?
$(document).ready(function() {
// add a hash to the URL when the user clicks on a tab
$('a[data-toggle="tab"]').on('click', function(e) {
history.pushState(null, null, $(this).attr('href'));
});
// navigate to a tab when the history changes
window.addEventListener("popstate", function(e) {
var activeTab = $('[href=' + location.hash + ']');
if (activeTab.length) {
activeTab.tab('show');
} else {
$('.nav-pills a:first').tab('show');
}
});
});
`
<ul id="myTab" class="nav nav-pills">
<li class="active"><a href="#tab1" data-toggle="tab">Tab1</a></li>
<li><a href="#tab2" data-toggle="tab">Tab2</a></li>
<li><a href="#tab3" data-toggle="tab">Tab3</a></li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane active" id="tab1">
<h2>Tab 1</h2>
<p>Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>
</div>
<div class="tab-pane" id="tab2">
<h2>Tab 2</h2>
<p>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p>
</div>
<div class="tab-pane" id="tab3">
<h2>Tab 3</h2>
<p>Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p>
</div>
</div>
Il 'history.pushState' è HTML5 che non è supportato in IE8 . 'popstate' è supportato solo in IE10. – putvande
@putvande Non sono sicuro di come implementarlo, ma dovrei usare [history.js] (https://github.com/browserstate/history.js/)? Funzionerebbe per me? – Metzed