When developing a mobile application, it is necessary to preload pages that need to be linked. Because when a linked page is set to preload mode, the target page is automatically loaded into the current document after the current page is loaded, and the user can click to open it immediately, which greatly speeds up the page access.
Add a <a> element to the new HTML page, set the value of the element's href attribute to "text.html", and set the value of the "Data-prefetch" property to "true" to indicate the link page of the preloaded <a> element:
<! DOCTYPE html>
In jquery Mobile, there are two ways to implement a page preload, as follows:
1. Add the "Data-prefetch" attribute to the element that needs to link the page. 2. Call the global Method $.mobile.loadpage () in the JavaScript code to preload the specified target HTML page, with the final effect of setting the element's "Data-prefetch" property as follows:
<script type= "Text/javascript" >
$ (function () {
$.mobile.loadpage ("text.html");
})
</script>
Page Caching
In jquery Mobile, the historical content that has been visited can be written to the cache of the page document in the form of page caching, and when the user re-accesses it, it does not need to be reloaded, as long as it is read from the cache.
<body>
<div data-role= "page" >
<div data-role= "header" >
In jquery Mobile, there are two ways to implement page caching, as follows:
1. Add the "Data-dom-cache =" true "attribute to the element that needs to link the page. 2. Call the global Method $.mobile.loadpage () in the JavaScript code to preload the specified target HTML page, with the final effect of setting the element's "Data-prefetch" property as follows:
<script type= "Text/javascript" >
$ (function () {
$.mobile.page.prototype.options.domcache = true;
})
</script>