Hi,
I'm developing a site which serves some slow (up to around 4 sec. loading time) pages due to extensive database queries.
In order to let the users know that the new page is loading (also to prevent multiple clicks), I'm displaying a div with a fake loading bar on the page where the users clicked a link to a slow loading page.
Actually, showing the fake loading div is working very good. The DOM of the old page (with the fake loading bar) is still displayed when the new page is loading, which means the loading div is shown until the new page is ready to be displayed.
This is how it's done. HTML part:
<!-- link example which will execute the javascript -->
<a href="link/to/slow/page/" class="loading">slow page</a>
<!-- full screen div which gets displayed when clicking a
"loading" class link. -->
<div id="dim" style="display:none; top:0; left:0; width:100%; height:100%; z-index:9999;">
<div id="loading">
<p>loading data, please wait...</p>
<img src="loading.gif" alt="loading..." />
</div>
</div>
Javascript (jQuery) part:
$(".loading").each(function() {
$(this).click(function() {
$("#dim").fadeIn();
});
return true;
});
The Problem now is, that if a user clicks back in the browser (just tested with FF 3.6) from a slow page, the loading bar div is still shown sometimes.
Questions:
- Is this even a good way to design such a fake loading bar?
- If yes, is there a way to prevent the browsers from displaying the div when going back in the browser's history?
Thanks for any hints.
Conclusion:
looks like there's no easy way to fake it that way. I'm going for Ajax data retrieval with a real loading bar.