问题
I know that IE does not support pushState, but I want a way for my users with a modern browser to enjoy the benefits while the users using older browsers don't make use of it.
Currently, the javascript code prevents my tabbed navigation from working completely in IE, which means that cannot see a lot of the content.
Anyone know a solution for my problem?
Here's my JavaScript code:
var tabContents = $(".tab_content").hide(),
tabs = $(".tab_nav li");
tabs.first().addClass("active").show();
tabContents.first().show();
tabs.click(function() {
var $this = $(this),
activeTab = $this.find('a').attr('href');
history.pushState(null, '', activeTab);
if(!$this.hasClass('active')){
$this.addClass('active').siblings().removeClass('active');
tabContents.hide().filter(activeTab).fadeIn();
}
return false;
});
$(window).bind('popstate', function(){
$.getScript(location.href);
});
回答1:
Try the jQuery BBQ: Back Button & Query Library. I've had great success using it.
来源:https://stackoverflow.com/questions/6823825/pushstate-fallback-for-internet-explorer