I'm trying to use the rich-text editing command functions as described in MDN here
The API for this seems fairly simple. Select some text, and execute the command, and it'll wrap the content with it. Cool stuff!
In Firefox (Aurora), this works great:
document.execCommand('heading', false, 'H1');
However the same command in Chrome returns nothing. Is this not implemented the same way (or at all) in Chrome?
Thanks!
I am afraid Chrome does not support the heading command yet. You can check this page in Chrome for available commands: http://tifftiff.de/contenteditable/compliance_test.html
What you are looking for is the formatBlock command used like so:
document.execCommand('formatBlock', false, '<h1>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With