Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

html - What exactly is the HTML5 <command> tag and what is the browser support

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

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The <command> element is meant to be an abstraction to let you refer to the same "command" from multiple menu entries or buttons. AFAIK the idea is something like

<command id="doThat" onclick="doThat()"></command>
<input type="button" command="doThat" value="click me to do that">
<menu command="doThat">This does that too</menu>

Then, if you want to indicate that the user can not do that in the context, you could do

document.getElementById('doThat').disabled=true;

and both the button and the menu entry would become disabled. Or you could assign a shortcut key to the command element, and either menu and button would respond to the shortcut. Things like that.

I'm not sure but I think this part of HTML5 is unfinished and likely will be removed before HTML5 is released as a final specification? As-is, it is indeed unclear how it is intended to work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...