JQuery Mobile (v) Preload and page caching

Source: Internet
Author: User
Tags html page prefetch
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>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.