Working with GetSelection in IE

  •  07-25-2007, 9:53 AM

    Working with GetSelection in IE

    I have the following javascript code that executes when a custom toolbar button is clicked:

    function insertLink(sender)

    {

    var cuteEditor = CuteEditor_GetEditor(sender);

    var selection = cuteEditor.GetSelection();

    cuteEditor.PasteHTML('<a href="http://www.google.com" target="_blank">' + selection + '</a>');

    }

    In Firefox, this works the way I expected - the selected text in the editor becomes a hyperlink. However, in IE (specifically IE7), the selected text is replaced by "[object]" which becomes the hyperlink.
     
    Using Firebug to step through the code I see that the GetSelection() function does not just return a string but a javascript object. So my ultimate question is how do I use javascript to get access to just the selected text in IE.
     
    Thank you,
    Richard
View Complete Thread