深度学*高阶api_深度HTML API

发布时间:2021-10-16 09:40:38

深度学*高阶api






HTML深度 (HTML IN-DEPTH)




Are you a person who just started with HTML/CSS or someone who wants to have an in-depth knowledge of the advanced features of HTML? Then you are in the right place. So grab a cup of coffee and enjoy the first part of our HTML series, HTML APIs in Depth.


重新你们谁刚开始使用HTML / CSS或别人谁愿意有HTML的高级功能的深入了解一个人? 那么您来对地方了。 因此,喝杯咖啡,享受我们HTML系列文章的第一部分,即深度学*HTML API。


A few days before, I came across an article by Lea Verou, where she wrote about the design of HTML APIs and how we might write better documentation for web designers. There she pointed out a crucial aspect of our perception. She says:


几天前,我遇到了Lea Verou撰写的一篇文章 ,其中她撰写了有关HTML API设计以及如何为Web设计人员编写更好的文档的文章。 她在那里指出了我们看法的关键方面。 她说:



As JavaScript developers, we often forget that not everyone has the same knowledge as us. It’s called the curse of knowledge.


作为JavaScript开发人员,我们经常忘记并非每个人都拥有与我们相同的知识。 这就是知识的诅咒。



When beginners of HTML/CSS struggle to write code in JavaScript, that’s where HTML5 APIs come to their rescue. HTML APIs are a collection of JS libraries which can be used directly in HTML files without incorporating any customize JavaScript code


当HTML / CSS的初学者难以用JavaScript编写代码时,HTML5 API便应运而生。 HTML API是JS库的集合,可直接在HTML文件中使用,而无需合并任何自定义JavaScript代码


So in addition to specifying markup, HTML5 specifies scripting application programming interfaces (APIs) that can be used along with JavaScript.


因此,除了指定标记外,HTML5还指定可与JavaScript一起使用的脚本应用程序编程接口 (API)。


This technique helps us perform tasks in the web browser and supported mobile devices that were not possible in previous versions of HTML.


此技术可帮助我们在Web浏览器和受支持的移动设备中执行以前HTML版本无法完成的任务。


为什么选择HTML API (Why HTML APIs)

Now, many advanced JavaScript might question the need for such APIs. But these APIs not only benefit people with limited JavaScript skills but also help programmers save time by using simple APIs for tedious tasks. It makes the process more flexible for programming


现在,许多高级JavaScript可能会质疑对此类API的需求。 但是这些API不仅使JavaScript技能有限的人受益,而且通过将简单的API用于繁琐的任务来帮助程序员节省时间。 它使编程过程更加灵活


什么是API? (What is API?)

According to Wikipedia:


根据维基百科:



“An application programming interface (API) is a computing interface which defines interactions between multiple software intermediaries. It defines the kinds of calls or requests that can be made, how to make them, the data formats that should be used, the conventions to follow, etc.”


“应用程序编程接口( API )是一个计算接口,它定义了多个软件中介之间的交互。 它定义了可以进行的调用或请求的种类,如何进行调用,应使用的数据格式,遵循的约定等。”



In a typical HTML API, the calls and requests along with definitions and protocols are written and invoked with HTML itself. HTML API uses certain class or attribute patterns used in the HTML element to invoke the functions in the API.


在典型HTML API中,调用和请求以及定义和协议都是使用HTML本身编写和调用的。 HTML API使用HTML元素中使用的某些类或属性模式来调用API中的功能。


HTML API列表 (Lists of HTML APIs)

The canvas element for immediate mode 2D drawing.

立即模式 2D绘图的canvas元素 。

Timed media playback

定时播放媒体 Offline Web Applications

脱机Web应用程序 Document editing

文件编辑

Drag-and-drop

拖放式

Cross-document messaging

跨文档消息传递

Browser history management

浏览器历史记录管理

MIME-type and protocol handler registration

MIME类型和协议处理程序注册

Microdata

微数据

Web Storage, a key-value pair storage framework that provides behaviour similar to cookies but with larger storage capacity and improved API.

Web Storage ,一个键值对存储框架,提供类似于cookie的行为,但具有更大的存储容量和改进的API。

Web Workers

网络工作者

Geolocation ? get the latitude and longitude of the user’s browser

地理位置 -获取用户浏览器的纬度和经度

File ? get file information from local files selected via file input, or drag and drop

文件 -从通过文件输入选择的本地文件中获取文件信息,或拖放

History ? add or remove URLs in the browser’s history stack ? useful in single-page apps

历史记录 -在浏览器的历史记录堆栈中添加或删除URL-在单页应用程序中很有用

Audio API

音频API Video API

影片API

Some more commonly used HTML APIs would be:


一些更常用HTML API是:


High-Resolution Time API: Provides the current time in the sub-millisecond resolution which is not dependent on the system clock

高分辨率时间API :以毫秒级的分辨率提供当前时间,该时间与系统时钟无关

Navigation Timing API: Offers detailed timing information throughout the page load process

导航时序API :在整个页面加载过程中提供详细的时序信息

Network Information API. Provides estimation of bandwidth

网络信息API 。 提供带宽估算



Know more about such APIs here.


在此处了解有关此类API的更多信息。



HTML APIs are also capable of creating responsive reusable layouts with Web Components which work similar way as APIs.


HTML API还能够使用Web组件创建响应性的可重用布局,其工作方式与API相似。


For example the components like:


例如以下组件:


: Display a popup or modal window without the overheads

:显示弹出窗口或模式窗口,而没有额外的开销
& : Show/hide content under a collapsible heading without using JS

:在不使用JS的情况下在可折叠标题下显示/隐藏内容 : To add responsive pictures which respond to different viewports and serve specialised content

:添加可响应不同视口并提供专门内容的响应式图片 : to give instant feedback on form

:在表单上提供即时反馈

These components can be used in any HTML file without copying the whole HTML file. Let’s know a little bit more about them.


这些组件可以在任何HTML文件中使用,而无需复制整个HTML文件。 让我们进一步了解它们。


Web组件和HTML API? (Web Component and HTML API?)













Web Components allow the developer to divide the HTML website into chunks of reusable customized code. These customized codes can be used in any part of the whole project without the requirement of copying the whole HTML file. It will help developers to write more modular code.


Web组件使开发人员可以将HTML网站划分为可重用的自定义代码块。 这些自定义的代码可以在整个项目的任何部分中使用,而无需复制整个HTML文件。 它将帮助开发人员编写更多的模块化代码。


Building a Web Component uses four different specifications in the browser to construct, configure and generate their internal workings.


构建Web组件使用浏览器中的四个不同规范来构造,配置和生成其内部工作。


HTML templatesHTML structure elements are often repeated to make sure each one works the same as the last. Instead, to save some time and reduce errors, we can also make a function to generate HTML for an element, adjusting the contents as they go. HTML templates bring that ability natively to browsers through use of the