HTML DTD
DTD Document Type Defination:
原来每次带上的<!Doctype html>是这个意思
HTML head
- title
- base
- meta
- link
- script
script可以用于指定MIME类型。
MIME是Multipurpose Internet Mail Extensions的缩写,是一种描述消息内容类型的标准,用来表示文档、文件或字节流的性质和格式。¹ MIME消息可以包含文本、图像、音频、视频以及其他应用程序专用的数据。¹ 浏览器通常使用MIME类型(而不是文件扩展名)来确定如何处理URL,因此Web服务器需要正确地设置MIME类型。¹¹: 来自必应搜索结果第1页第1条,www.runoob.com/http/mime-t…
源: 与必应的对话, 2023/4/21(1) www.runoob.com/http/mime…. www.runoob.com/http/mime-t… 访问时间 2023/4/21.
浏览器通过响应头中的Content-Type字段指定MIME类型。如text/html表示html文档,image/jpeg表示JPEG图片。
HTML ARIA
并非仅为盲人使用,也可为UI设计提供指导。
Warning: Many of these widgets are fully supported in modern browsers. Developers should prefer using the correct semantic HTML element over using ARIA, if such an element exists. For instance, native elements have built-in keyboard accessibility, roles and states. However, if you choose to use ARIA, you are responsible for mimicking the equivalent browser behavior in script.
一进去就看到个warning。原来随着html的发展,大部分ARIA的功能已经有内置的html元素实现了,难怪说不用ARIA比用错好捏。
HTML5 存储方案
- cookies
- Web Storage
- IndexedDB
| cookies | Web Storage | IndexedDB | |
|---|---|---|---|
| Storage | Small lookup table with pairs of key, data values | Strings only. Key,value storage | ObjectStore that can store any type of data including objects |
| Capacity | 4KB | 5MB-25MB | 50MB upwards |
| Indexing | Not Available | Not Available | Available |
| API Call Type | Synchronous | Synchronous | Asynchronous |
| Operation Performance | Directly performed | Directly performed | Transactional |
| Learning Curve | Low | Low | High |
根据网上搜索结果,计算机中的transaction指的是一组相关的操作,需要作为一个单一的操作执行。换句话说,transaction是一个逻辑工作单元,其效果在transaction之外要么完全可见,要么完全不可见。我们需要这样做来确保我们的应用程序中的数据完整性。
根据网上搜索结果,transaction是怎么实现的:
- transaction的实现方式有多种,其中一种是两阶段提交协议(或2PC),它是一种用于在不同的软件组件(如多个数据库、消息队列等)之间实现transaction的机制¹。
- 2PC的架构包括两个重要的参与者:transaction协调器和transaction参与者。transaction协调器负责管理transaction的整个生命周期,transaction参与者负责执行transaction中的具体操作¹。
- 2PC分为两个阶段:准备阶段和提交阶段。在准备阶段,transaction协调器向所有的transaction参与者发送准备消息,要求它们准备执行transaction,并等待它们的响应。如果所有的transaction参与者都返回了同意消息,那么transaction协调器就进入提交阶段,向所有的transaction参与者发送提交消息,要求它们正式执行transaction,并等待它们的响应。如果有任何一个transaction参与者返回了拒绝消息,那么transaction协调器就进入回滚阶段,向所有的transaction参与者发送回滚消息,要求它们撤销已经执行的操作,并等待它们的响应¹。
源: 与必应的对话, 2023/4/21(1) www.baeldung.com/transactio…. www.baeldung.com/transaction… 访问时间 2023/4/21.
怎么看完之后感觉还是不懂transaction呢😭
HTML5 web worker
web worker重开了一个后台线程。可以在后台运行任务而不阻碍用户界面。web worker甚至不与当前界面共享同一个window对象。
work与主线程通信:
first.onchange = () => {
myWorker.postMessage([first.value, second.value]);
console.log("Message posted to worker");
};
second.onchange = () => {
myWorker.postMessage([first.value, second.value]);
console.log("Message posted to worker");
};
HTML5 web socket
web socket是一种用于创建和管理与服务器的连接,以及在连接上发送和接收数据的API。一个简单的web socket的代码示例如下:
// Create a new WebSocket object
var ws = new WebSocket("ws://example.com/socketserver");
// Define the behavior when the connection is opened
ws.onopen = function(event) {
// Send a message to the server
ws.send("Hello, server!");
};
// Define the behavior when a message is received from the server
ws.onmessage = function(event) {
// Log the message from the server
console.log("Message from server: " + event.data);
};
// Define the behavior when the connection is closed
ws.onclose = function(event) {
// Log the closing code and reason
console.log("Connection closed: " + event.code + " " + event.reason);
};
// Define the behavior when an error occurs
ws.onerror = function(event) {
// Log the error message
console.error("WebSocket error: " + event.message);
};