Using GetSelection() in stand along javascript file.

Last post 10-30-2007, 4:06 PM by ElMatador. 3 replies.
Sort Posts: Previous Next
  •  10-17-2007, 1:33 PM 34397

    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






  •  10-17-2007, 1:38 PM 34398 in reply to 34397

    Re: Using GetSelection() in stand along javascript file.

    By the way, selectedText above is the cutesoft editor object that gets passed into the Javascript function, thanks.
  •  10-17-2007, 3:32 PM 34400 in reply to 34397

    Re: Using GetSelection() in stand along javascript file.

    George,
     
    >>The code above that is bold red does NOT return the currently selected text.
     
    How did you get this conclusion?

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  10-30-2007, 4:06 PM 34725 in reply to 34400

    Re: Using GetSelection() in stand along javascript file.

    Adam,

    I dont know how I came to that conclusion. Can you tell me how to retrieve the Selected Text in a stand alone javascript file?

    Thanks

View as RSS news feed in XML