HTML5 <command> 到底是什么?标签和浏览器支持是什么

我已阅读 HTML5 规范 <command> 发现这个元素的信息很模糊.

I've read the HTML5 spec for <command> and found the information on this element very vague.

我试过了,发现不是strong> 在 Chrome(最新版本)中工作,它正在 在 Safari(甚至更旧的版本)上工作,抱歉没有 FF(请不要开枪) - 仅 Mac 测试.

I've tried it out and found that it is not working in Chrome (latest version) and it is working on Safari (even older ones), sorry no FF (don't shoot me please) - Mac only test.

我不明白这个元素有什么用,或者即使我使用正确.

I can't understand what is the use of this element or even if I'm using it correctly.

提前感谢您对此的任何澄清!

I thank you in advance for any clarification about it!

推荐答案

顺便说一句,它适用于 Windows 的 Firefox 3.6.13.

It works on Firefox 3.6.13 from Windows by the way.

命令元素旨在封装您可以执行的操作.它可以在菜单中呈现(因为菜单呈现您可以调用的项目).

The command element is meant to encapsulate something that you can do. It can be rendered within a menu (since a menu presents items you can invoke).

它在 UI 和命令之间提供了一个抽象层,以便您可以使多个 UI 元素引用同一个命令.这为您提供了在菜单中呈现一个命令元素的灵活性,该元素也可以通过页面中间的 URL 以及页面底部的按钮调用.禁用该命令会禁用该命令背后的操作的所有访问路径(url/button/menu).

It provides an abstraction layer between UI and commands, so that you can make multiple UI elements refer to the same command. This gives you the flexibility of having one command element, rendered in a menu, that is also invoked via a URL in the middle of the page as well as a button at the bottom of the page. Disabling the command disables all access paths (url/button/menu) to the action behind the command.

目前关于如何将其链接到多个元素实际工作的信息非常少(因为浏览器才刚刚开始实现它!) 但这是其中之一它的意图.

There is currently very scarce information as to how linking it to multiple elements will actually work (since browsers have only just started implementing it!) but that is one of its intentions.

目前,唯一记录在案的用法是提供一个语义上唯一的标签来指定(不使用 <input> 元素)它是 <menu> 中的 command,从而允许真正的"由浏览器呈现的菜单(实现时).

At the present moment, the only documented usage is to provide a semantically unique tag to specify (without using <input> or <button> elements) that it is a command within a <menu>, thereby allowing "real" menu rendering by the browser (when implemented).

相关文章