をバック有効ブートストラップ2.3.2 IE8でTwitterのブートストラップタブでの取り扱いボタン+
私はコンテンツを表示するために私のプロジェクトにブートストラップからtabsを使用しています。 1つのページには異なるコンテンツの複数のタブがあり、そのタブにはユーザーをウェブサイト上の他のページに誘導するリンクがあります。
デフォルトでは、タブは戻るボタンのナビゲーションをサポートしていないため、ユーザーが別のページにアクセスしてブラウザの戻るボタンを押すと、そのタブはアクティブなときに最初に開いたタブに戻ります彼らは最後にページを見ました。
以下のJavascriptはFrançois ZaninottoからChrome、Firefox、Safariでこの問題を解決します。 FrançoisはIE8 +でも動作すると言いますが、私のテストではIE8、IE9、IE10で動作させることはできません。誰もIE8 +でこれを動作させる方法を知っていますか?出来ますか?
$(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>
'history.pushState'があるHTML5を。 'popstate'はIE10でのみサポートされています。 – putvande
@putvande実装方法はわかりませんが、[history.js](https://github.com/browserstate/history.js/)を使うべきですか?それは私のために働くだろうか? – Metzed