ExecCommand, insertlink and Firefox

Last post 02-09-2007, 4:17 PM by lamasse. 2 replies.
Sort Posts: Previous Next
  •  02-09-2007, 2:31 PM 26568

    ExecCommand, insertlink and Firefox

    Hi,

    I'm trying to insert links from an external dropdown into the editor. I'm using editor.ExecCommand('insertlink', false, 'MyUrl') .
    It works fine in IE but in Firefox, it opens the Link popup instead of pasting my link....

    Is there any workaround or fix for this issue ?

    Thank you,

    Vincent

    Filed under: , ,
  •  02-09-2007, 2:50 PM 26572 in reply to 26568

    Re: ExecCommand, insertlink and Firefox

    Vincent,
     
    Can you use PasteHTML API?
     
    PasteHTML()

    This method is used for pasting the specified HTML into a range within a editor document. If anything is selected, the selection is replaced with the new HTML and text.

    Example:

    // get the cute editor instance
    var editor1 = document.getElementById('<% = Editor1.ClientID%>');

    // pasting the specified HTML into a range within a editor document
    editor1.pasteHTML("<a href='http://yahoo.com'>Hello World</a>");

    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

  •  02-09-2007, 4:17 PM 26581 in reply to 26572

    Re: ExecCommand, insertlink and Firefox

    Hi Adam,
    Thanks for your answer.

    This is basically what I did. I needed to get current selection as well, so here is the trick :

    //Function to get current selection in IE (6 & 7) and Firefox (2.0)
    function getSel() {
        var editor = document.getElementById('CE_Editor1_ID');
        var txt = editor.GetSelection();
         if(txt == '[object]') {
           //In IE we need this trick
            txt = txt.createRange().text;
         }
        return txt;
    }


    Vincent
View as RSS news feed in XML