2

Perhaps you have heard about JavaScript Document's execCommand() function, which we often use to make rich text editors. It had a bad reputation before as Internet Explorer worked differently with it. Here are my questions.

  1. Today, do all the elements of execCommand work on all browsers? Like save as, bold, italic, etc...?

  2. If you want to make a rich text editor, is execCommand the appropriate choice today?

  3. Can you give me a website where I can find all the elements this function offers? Because I visited some, but they are just showing bold, italic and others. I want the complete updated lists.

Marcus
  • 6,697
  • 11
  • 46
  • 89
user1780468
  • 117
  • 3
  • 8
  • 1
    I know javascript very well, and I don't know of an exec command. I know of an exec method for regex, but not something to do with rich text editors. I think you are mistaken somewhere, or missing out a huge chunk of info. – Billy Moon Nov 02 '12 at 20:03
  • 1
    Do you mean `document.execCommand`? – j08691 Nov 02 '12 at 20:06

2 Answers2

0

Quirksmode has an (oldish) compatibility table of document.execCommand.

I think the best would be to mix execCommand with selection/range & DOM manipulation for a rich-text editor.

Edit:

Related questions:

Community
  • 1
  • 1
pozs
  • 34,608
  • 5
  • 57
  • 63
  • @user1780468 `Quirksmode is not updated...` yes, i know, that's why i wrote oldish, but there you can see which commands exists (& if you want to support older browsers too - like IE 6/7 - it is the best source) – pozs Nov 02 '12 at 20:20
  • createrange has issues in chrome and IE. Based on all functions I want, they work in all current browsers, I just read on it. IE 6 and 7 will have issues, but I dont think this will be a big problem as many people do no it use them... So, I will go with document.execcommand... I will ad more features.... By the way, adding too much things in rich text editor will not help you.. People who use CKEditor or TinyMCE, do not use all the functions of them.. – user1780468 Nov 02 '12 at 20:46
0

I had a similar requirement and came across a rich source of such commands. This list is exhaustive, IMO, and also provides compatibility with various browsers.

http://help.dottoro.com/larpvnhw.php

I've not been able to make it work with Chrome at all, while some work with IE and all the commands run smoothly with Firefox.

Hope this helps.

Rohit
  • 1