execCommand - is there a better way? RRS feed

  • Question

  • Hello.

    Is there a better way to keep the current selection when using execCommand().

    The code below works, but im thinking there must be a better way.


    So what it does is to get the Range from the current selection and put that in the current selection, witch feels stupid. I could keep an up to date Range object as a variable and put that into the current selection rather then first getting it and then adding it instantly, and I should also clear out any old range before I add the new, but it all feels wrong.

    Do you know of a good way of doing it?

    Tuesday, September 25, 2012 5:50 PM


  • Hi,

    Why you don't define a null function to do that?

    For example:

    function set() {
                editorDoc.execCommand('foreColor', false, "");

    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com
    Microsoft One Code Framework

    • Proposed as answer by Song Tian Thursday, October 11, 2012 8:02 AM
    • Marked as answer by Dino He Thursday, October 11, 2012 2:19 PM
    Wednesday, September 26, 2012 7:59 AM