I have this jQuery ajax navigation tabs plugin that I created with some help from CSS-Tricks.com and the jQuery hashchange event plugin (detects hash changes in browsers that don't support it).
The code does not last long to publish it here, but it looks something like this:
Part 1) When a tab is clicked, it gets the href attribute of that tab and adds it to the browser navigation bar, for example '#tab_name': window.location.hash = $(this).attr("href");
Part 2) When the navigation bar changes (hash change), it receives the href change as follows: window.location.hash.substring(1);(the substring should get only "tab_name" without "#"), and then call the ajax function to get the information to display.
I want to automatically run the plugin to load the first tab when accessing the page, so at the beginning of the code that I put:
if (window.location.hash === '') {
window.location.hash = '#tab_1';
$(window).trigger('hashchange');
}
The problem is that it works in FF, but not in Chrome, I mean that everything works, but it $(window).trigger('hashchange');doesn't seem to work because it does not get the first tab.
Any suggestions
Note. It worked some time ago, but suddenly it doesn’t happen (maybe a Chrome update).
source
share