How to Implement html5 offline applications ?, For many friends, it may not be very clear about how to develop html5 offline applications. The following section will help you develop html5 offline applications! A friend in need has seen it!
Html5 Offline Application Implementation Method:
The description of html5 offline applications is not mentioned here. Google or Baidu is required. This article aims to introduce how to develop offline applications;
Step 2: Create a manifest file and specify a list of cached files;
You can create a file with the suffix of txt text. The first line must be written to the cache manifest;
In the second line, you can write an optional description # version 1.0, which starts with #. Here, it indicates the version number;
At the beginning of the third line, each line has a file path relative to the current file directory, for example:
Static/img/logo.png
Static/css/style.css
You can write a basic manifest file and change the file suffix to. manifest;
Step 2: Specify the file manifest attribute in the html file as the path of the cache. mnifest file;
After the manifest attribute is added, the page is loaded. The files in the cached configuration file will be cached offline and will not be read from the server when the configuration file is refreshed again;
Step 2: refresh the cache through the API interface;
Use JS through window. applicationCache is used to obtain offline cache objects, and the update method is called: window. applicationCache. update () to call the download of the current cache file. After the download is complete, the updateready event of the offline cache object is triggered. The swapCache method is executed by binding the event to clear the cache: window. applicationCache. swapCache (), this will not cause the previously loaded resources to be suddenly reloaded, but the resources on the requested page will be updated afterwards;
The above is the method for implementing HTML5 offline applications. Please try it!
You still like the following:
Large inventory of HTML5 development tools: 10 models should be evaluated