Using GetSelection() in stand along javascript file.

  •  10-17-2007, 1:33 PM

    Using GetSelection() in stand along javascript file.

    Dear Support,

    I am trying to implement a custom Link Chooser (link icon).
    I have code set up that when the link icon gets clicked, it calls a stand alone (in its own file) javascript function.

    This javascript function attempts to get the "Selected Text" that the user is trying to add an A tag to.

    This is the code that I have:

    *****
        var popupLink_Start = "", popupLink_End = "", popupLink_Selection = "";   
        var items;
        var originalText = selectedText.getHTML();

        // Get the current Selection text
        popupLink_Selection = selectedText.GetSelection();
        // unlink the current selection, in case its already linked using Cute's Javascript API
        selectedText.GetSelection().createRange().execCommand("Unlink");
        // Split the editor content
        items = new String(selectedText.getHTML()).split(poupLink_Selection);
        // Get the Front portion of the content and the Rear portion of the content in terms of selected text   
        popupLink_Start = items[0];
        popupLink_End = items[1];
         result = window.showModalDialog(path + "LinkChooser.aspx?siteId=" + siteId + "&linkId=" + arguments[2].value  + "&v=", null, "height=400,width=350,status=no,toolbar=no,menubar=no,location=no,scrollbars=no");

        selectedText.ExecCommand("insertlink",false,result[0]);
        selectedText.focus();

    ******
       
    The code above that is bold red does NOT return the currently selected text.

    What am I doing wrong? Do I have to have this Javascript function in the same page as the cute editor?

    Please let me know, thank you, regards,

    George Gomez






View Complete Thread