问题
I believe that most of you have heard of preloading of images.
But is there anyone who knows how we can preload webpages?
For instance, when we are login to GMAIL, we will see a loading progress bar.
How do we preload html webpages/web applications (non-flash based ) as per what gmail is doing?
best Regards
回答1:
Due to the stateless nature of the HTTP protocol, pre-loading webpages could be challenging. One way to achieve this would be to have a minimal HTML sent to the client initially and then progressively enhance parts of the site using AJAX. During the time those AJAX requests are being executed you could have some spinner on the page saying that the site is being loaded, but if you want to have real progress bars (such as the one GMail uses) things become even more challenging.
回答2:
Google uses AJAX requests on GMail, you could do the same with jQuery. If you wanted to replace the entire code between on a page.
function preload(url2load,anyDataIfAny) {
$.ajax({
type: 'POST',
url: url2load,
data: anyDataIfAny,
success: function(data) {
$(html).html(data);
}
});
}
This will show the user the loading screen until the page is loaded, then replace the loading screen with the requesting code.
回答3:
Try this:
http://www.gayadesign.com/diy/queryloader-preload-your-website-in-style/
回答4:
Depends alot on what you want to achieve..?
But generally, you could load the (next?) page into a hidden iframe.
- unveiling it when that becomes prudent..
来源:https://stackoverflow.com/questions/3275056/preloading-of-html-web-page-or-non-flash-web-applications