HTML <html> manifest 属性

本文介绍了HTML5中manifest属性的应用,通过该属性可以指定缓存清单文件的位置,实现Web应用的离线浏览、快速加载及减少服务器负载等功能。文章还提供了一个具体的HTML文档示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

HTML <html> manifest 属性

定义和用法

manifest 属性规定文档的缓存 manifest 的位置。

HTML5 引入了应用程序缓存,这意味着 Web 应用程序可以被缓存,然后在无互联网连接的时候进行访问。

应用程序缓存使得应用程序有三个优点:

  1. 离线浏览 - 用户可以在离线时使用应用程序
  2. 快速 - 缓存的资源可以更快地加载
  3. 减少服务器加载 - 浏览器只从服务器上下载已更新/已更改的资源

manifest 属性应该被 Web 应用程序中您想要缓存的每个页面包含。

manifest 文件是一个简单的文本文件,列举出了浏览器用于离线访问而缓存的资源。


语法

<html manifest=" URL">

属性值

描述
URL 文档的缓存 manifest 的地址。

可能的值:

  • 绝对 URL - 指向另一个网站(比如 href="http://www.example.com/demo.appcache")
  • 相对 URL - 指向网站内的一个文件(比如 href="demo.appcache")

实例

带有缓存 manifest 的 HTML 文档(用于离线浏览):

<!DOCTYPE html>
<html manifest="demo_html.appcache">
<meta charset="UTF-8">
<body>
<script src="demo_time.js">
</script>
<p id="timePara"><button onclick="getDateTime()">获取日期和时间</button></p>
<p><img src="logo.png" width="336" height="69"></p>
<p>尝试打开 <a href="tryhtml5_html_manifest.htm" target="_blank">这个页面</a>, 在离线的状态下重新载入这个页面,页面也可以访问。</p>
</body>
</html>



本文转自:http://www.runoob.com/tags/att-html-manifest.html

<resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>*.properties</include> <include>*.yml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>*.sql</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> <includes> <include>static/**</include> </includes> <targetPath>${project.build.outputDirectory}</targetPath> </resource> </resources> server.port=8081 server.servlet.context-path=/demo logging.level.com.esoft.crm.mapper=debug spring.datasource.url=jdbc:h2:file:./test;MODE=MySQL;CASE_INSENSITIVE_IDENTIFIERS=TRUE;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false spring.datasource.driver-class-name=org.h2.Driver spring.datasource.username=sa spring.datasource.password= spring.h2.console.enabled=true spring.h2.console.path=/h2-console #spring.sql.init.mode=always #spring.sql.init.schema-locations=classpath:schema.sql #spring.sql.init.data-locations=classpath:data.sql spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect logging.level.org.hibernate.SQL=debug logging.level.org.hibernate.type.descriptor.sql=trace spring.datasource.hikari.connection-timeout=30000 spring.datasource.hikari.maximum-pool-size=10 #spring.sql.init.mode=always #spring.sql.init.schema-locations=classpath:schema.sql #spring.sql.init.data-locations=classpath:data.sql spring.datasource.schema=classpath:schema.sql spring.datasource.data=classpath:data.sql spring.datasource.initialization-mode=always spring.web.resources.static-locations=classpath:/static/ spring.mvc.static-path-pattern=/static/** mybatis.mapper-locations=classpath:mapper/*.xml mybatis.type-aliases-package=com.esoft.crm.po,com.esoft.crm.vo 且前端页面资源(css,img,index.html)等都存在与resource/static下,且没有打包,直接在idea环境下运行,运行后前端打不开,报错GET http://localhost:8080/js/chunk-vendors.1a0a0613.js net::ERR_CONNECTION_REFUSED :8080/img/icons/favicon-32x32.png:1 GET http://localhost:8080/img/icons/favicon-32x32.png net::ERR_CONNECTION_REFUSED :8080/img/icons/android-chrome-192x192.png:1 GET http://localhost:8080/img/icons/android-chrome-192x192.png net::ERR_CONNECTION_REFUSED :8080/img/icons/favicon-16x16.png:1 GET http://localhost:8080/img/icons/favicon-16x16.png net::ERR_CONNECTION_REFUSED localhost/:1 Error while trying to use the following icon from the Manifest: http://localhost:8080/img/icons/android-chrome-192x192.png (Download error or resource isn't a valid image),访问http://localhost:8081/demo/static/js/chunk-vendors.1a0a0613.js成功,内容是...//# sourceMappingURL=chunk-vendors.1a0a0613.js.map
最新发布
07-03
现在出现如下错误: AndroidManifest.xml文件的错误: 错误处代码:android:name=".MyApplication" 错误信息:Class referenced in the manifest, `com.example.floatingsearchapp.MyApplication`, was not found in the project or the libraries 错误信息:Unresolved class 'MyApplication' 错误处代码:<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> 错误信息:READ_EXTERNAL_STORAGE is deprecated (and is not granted) when targeting Android 13+. If you need to query or interact with MediaStore or media files on the shared storage, you should instead use one or more new storage permissions: `READ_MEDIA_IMAGES`, `READ_MEDIA_VIDEO` or `READ_MEDIA_AUDIO`. 错误处代码:<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 错误信息:WRITE_EXTERNAL_STORAGE is deprecated (and is not granted) when targeting Android 13+. If you need to write to shared storage, use the `MediaStore.createWriteRequest` intent. MainActivity.kt文件的错误: 错误处代码:startActivityForResult(intent, 100) 错误信息:<html>'startActivityForResult(Intent, Int): Unit' is deprecated. This method has been deprecated in favor of using the Activity Result API<br/>which brings increased type safety via an {@link ActivityResultContract} and the prebuilt<br/>contracts for common intents available in<br/>{@link androidx.activity.result.contract.ActivityResultContracts}, provides hooks for<br/>testing, and allow receiving results in separate, testable classes independent from your<br/>activity. Use<br/>{@link #registerForActivityResult(ActivityResultContract, ActivityResultCallback)}<br/>passing in a {@link StartActivityForResult} object for the {@link ActivityResultContract}.
06-22