I'm not referring to preloading images, I want to preload an HTML page using JQuery.
Why yes it is! You could do something like having an iframe for your content, fetching the content separately, and then filling the frame.
You could put everything in a div that is not visible, and once the document is ready, make the div visible - although this really isn't "pre-loading" - it is just not displaying anything until everything is loaded.
Set a class on the body to hide it, then remove it using Javascript at the onload event.
(But why you would want to do this is another question.)
Is this link any help to you? http://www.innovatingtomorrow.net/2008/04/30/preloading-content-jquery
Ajax the content in then use as you wish:
var myPrefetchedPage;
$.ajax({
url: "test.html",
cache: false,
success: function(html){
myPrefetchedPage = html;
}
})
myPrefetchedPage is now the full content - which can be injected into the current page (completely replacing the page if required.
If you are just trying to leverage caching as much as possible a hidden iFrame may work better. You can then use jQuery to cycle the iframe src to fetch multiple pages.
Yes, you can load the page via jQuery.get and then do what you want to with it (in string form) before displaying it. If you insert it into a hidden container, you can manipulate it with the DOM first.