How can I change font size to 30px (for example) using document.execCommand?
This:
document.execCommand(\"fontSize\", false, \"30px\");
It's a limitation of the FontSize command. There are various options I can think of:
document.execCommand("fontSize", false, "7"); and then finding the elements the command has created and changing them as required. See example: http://jsfiddle.net/S3ctN/. This obviously depends on there being no other elements with size 7 in the document and it also relies on the browser using elements for font size, which it seems they all do.