document.execCommand

document.execCommand 在firefox浏览器执行不好,但是在其他浏览器有时候使用会非常方便。

比如在input标签中使用:

onkeyup="if(isNaN(value))execCommand('undo');"

可以防止用户输入非数字的字符。

文章:document.execCommand()的用法小记 列出了很多可用的命令。

原文地址:https://www.cnblogs.com/Tpf386/p/8444737.html