ちょいと調べもの
Javascriptでというか、HTML Editing APIなるものがあって、そこの中に、document.execCommand()なるAPIがある。で、こいつにどんなコマンドが使えるのか調べてみた。
多分、最新のドキュメントはこいつ。Work in Progress – Last Update 13 February 2014だけど。。。
W3C HTML Editing APIs
IEの一覧は Windows Internet Explorer Command Identifiersに出てる。
これらのコマンドは、document.quaeryCommandSupported()でサポートしているかどうかを調べることができる。
ということで、さくっと調べてみた。
使ったスクリプトは
var commands = [ “backColor”, “bold”, ... “Unselect”];
window.onload = function () {
var tb = document.getElementById(‘result’);
for(var i = 0; i < commands.length; i++) {
var cmd = commands[i];
var tr = document.createElement('tr');
var td1 = document.createElement('td');
td1.textContent = cmd;
tr.appendChild(td1);
var td2 = document.createElement('td');
td2.textContent = document.queryCommandSupported(cmd);
tr.appendChild(td2);
tb.appendChild(tr); } }
コマンド一覧を配列で持っておいて、ぐるぐる回しながらテーブルの中身を詰めるコード。
ファイルはこちら。。というかリンク、クリックしたらスクリプト走るけど。。
Safari Mac OS X 8.0.2 (10600.2.5)
Chrome Mac OS X 39.0.2172.95
IE Windows 8.1
で確認しました。
command | Safari | Chrome | IE |
---|---|---|---|
backColor | TRUE | TRUE | true |
bold | TRUE | TRUE | true |
createLink | TRUE | TRUE | true |
fontName | TRUE | TRUE | true |
fontSize | TRUE | TRUE | true |
foreColor | TRUE | TRUE | true |
hiliteColor | TRUE | TRUE | true |
italic | TRUE | TRUE | true |
removeFormat | TRUE | TRUE | true |
strikethrough | TRUE | TRUE | true |
subscript | TRUE | TRUE | true |
superscript | TRUE | TRUE | true |
underline | TRUE | TRUE | true |
unlink | TRUE | TRUE | true |
delete | FALSE | FALSE | true |
formatBlock | TRUE | TRUE | true |
forwardDelete | TRUE | TRUE | false |
indent | TRUE | TRUE | true |
insertHorizontalRule | TRUE | TRUE | true |
insertHTML | TRUE | TRUE | false |
insertImage | TRUE | TRUE | true |
insertLineBreak | TRUE | TRUE | false |
insertOrderedList | TRUE | TRUE | true |
insertParagraph | TRUE | TRUE | true |
insertText | TRUE | TRUE | false |
insertUnorderedList | TRUE | TRUE | true |
justifyCenter | TRUE | TRUE | true |
justifyFull | TRUE | TRUE | true |
justifyLeft | TRUE | TRUE | true |
justifyRight | TRUE | TRUE | true |
outdent | TRUE | TRUE | true |
copy | FALSE | FALSE | true |
cut | FALSE | FALSE | true |
defaultParagraphSeparator | TRUE | TRUE | true |
paste | FALSE | FALSE | true |
redo | TRUE | TRUE | true |
selectAll | TRUE | TRUE | true |
styleWithCSS | TRUE | TRUE | false |
undo | TRUE | TRUE | true |
useCSS | TRUE | TRUE | false |
2D-Position | FALSE | FALSE | true |
AbsolutePosition | FALSE | FALSE | true |
BackColor | TRUE | TRUE | true |
BackgroundImageCache | FALSE | FALSE | true |
ms-beginUndoUnit | FALSE | FALSE | true |
BlockDirLTR | FALSE | FALSE | true |
BlockDirRTL | FALSE | FALSE | true |
Bold | TRUE | TRUE | true |
BrowseMode | FALSE | FALSE | true |
ClearAuthenticationCache | FALSE | FALSE | true |
ms-clearUndoStack | FALSE | FALSE | true |
Copy | FALSE | FALSE | true |
CreateBookmark | FALSE | FALSE | true |
CreateLink | TRUE | TRUE | true |
Cut | FALSE | FALSE | true |
DefaultParagraphSeparator | TRUE | TRUE | true |
Delete | TRUE | TRUE | true |
DirLTR | FALSE | FALSE | true |
DirRTL | FALSE | FALSE | true |
EditMode | FALSE | FALSE | true |
ms-endUndoUnit | FALSE | FALSE | true |
FontName | TRUE | TRUE | true |
FontSize | TRUE | TRUE | true |
ForeColor | TRUE | TRUE | true |
FormatBlock | TRUE | TRUE | true |
HiliteColor | TRUE | TRUE | true |
Indent | TRUE | TRUE | true |
InlineDirLTR | FALSE | FALSE | true |
InlineDirRTL | FALSE | FALSE | true |
InsertButton | FALSE | FALSE | true |
InsertFieldset | FALSE | FALSE | true |
InsertHorizontalRule | TRUE | TRUE | true |
InsertIFrame | FALSE | FALSE | true |
InsertImage | TRUE | TRUE | true |
InsertInputButton | FALSE | FALSE | true |
InsertInputCheckbox | FALSE | FALSE | true |
InsertInputFileUpload | FALSE | FALSE | true |
InsertInputHidden | FALSE | FALSE | true |
InsertInputImage | FALSE | FALSE | true |
InsertInputPassword | FALSE | FALSE | true |
InsertInputRadio | FALSE | FALSE | true |
InsertInputReset | FALSE | FALSE | true |
InsertInputSubmit | FALSE | FALSE | true |
InsertInputText | FALSE | FALSE | true |
InsertMarquee | FALSE | FALSE | true |
InsertOrderedList | TRUE | TRUE | true |
InsertParagraph | TRUE | TRUE | true |
InsertSelectDropdown | FALSE | FALSE | true |
InsertSelectListbox | FALSE | FALSE | true |
InsertTextArea | FALSE | FALSE | true |
InsertUnorderedList | TRUE | TRUE | true |
Italic | TRUE | TRUE | true |
JustifyCenter | TRUE | TRUE | true |
JustifyFull | TRUE | TRUE | true |
JustifyLeft | TRUE | TRUE | true |
JustifyNone | TRUE | TRUE | true |
JustifyRight | TRUE | TRUE | true |
LiveResize | FALSE | FALSE | true |
MultipleSelection | FALSE | FALSE | true |
Open | FALSE | FALSE | true |
Outdent | TRUE | TRUE | true |
OverWrite | FALSE | FALSE | true |
Paste | FALSE | FALSE | true |
ms-pasteContentOnly | FALSE | FALSE | true |
ms-pasteTextOnly | FALSE | FALSE | true |
PlayImage | FALSE | FALSE | true |
TRUE | TRUE | true | |
Redo | TRUE | TRUE | true |
Refresh | FALSE | FALSE | true |
RemoveFormat | TRUE | TRUE | true |
RemoveParaFormat | FALSE | FALSE | true |
SaveAs | FALSE | FALSE | true |
SelectAll | TRUE | TRUE | true |
SizeToControl | FALSE | FALSE | true |
SizeToControlHeight | FALSE | FALSE | true |
SizeToControlWidth | FALSE | FALSE | true |
Stop | FALSE | FALSE | true |
StopImage | FALSE | FALSE | true |
StrikeThrough | TRUE | TRUE | true |
Subscript | TRUE | TRUE | true |
Superscript | TRUE | TRUE | true |
UnBookmark | FALSE | FALSE | true |
Underline | TRUE | TRUE | true |
Undo | TRUE | TRUE | true |
Unlink | TRUE | TRUE | true |
Unselect | TRUE | TRUE | true |