Skip to content Skip to sidebar Skip to footer

Navigation Bar That Doesn't Reload

I have what is probably a very stupid question. I have been writing a Ruby On Rails app for the last few weeks, using the excellent Bootstrap/Twitter components to avoid me having

Solution 1:

The boostrap site's navbar does seem to be static during reloads but it isn't some clever js that is doing that. There is no hidden content that is being displayed.

What's happening here is a very fast page load. The guys at boostrap moved all their js links and scripts to the bottom of their html so their pages load faster, they even say that in their html. The pages load so much faster that certain elements like the navbar don't seem to change at all. I tried it on my on site and low and behold the static navbar illusion.

So maybe moving your js and scripts to the bottom of your html can help you achieve the same trick.

Solution 2:

The entire page (each tab) is loaded, and hidden when the page loads.

The URL is changed using location.hash when the links are clicked (and JavaScript is blocking navigation).

When the hash is changed, the onhashchange event is ran, and the correct div is shown.

Here is an example: http://jsfiddle.net/uFgtS/ (Well, I guess you can't see the url change. Copy the HTML, CSS and JS into a file and run it.)

Post a Comment for "Navigation Bar That Doesn't Reload"