can't change the href of a link programatically, it reverts automatically....

  •  07-27-2010, 7:41 AM

    can't change the href of a link programatically, it reverts automatically....

    Hi there,
     
    I'm evaluating CuteEditor and I've encountered two problems. For now, I'll talk about the later because it is essencial to continue with CuteEditor.
     
    I have this text in a CuteEditor loaded from an aspx page:

    Once in the <a href="http://www.cnn.com/">far west</a>.

    On HTML mode, I then change the url from cnn.com to nbc.com.

    Back to normal mode I place the cursor in the middle of "far west" and then click a custom button which runs this code:

    var editor1 = document.getElementById(EditorID);
    var tempUrl = 'http://tempuri.org/tempuri.html';
    editor1.ExecCommand('insertlink',null,tempUrl);
    var links = editor1.GetDocument().getElementsByTagName('a');
    for (var i=0;i<links.length;i++)
    {
     if (links[i].href == tempUrl)
     {
      link = links[i];
      break;
     }
    }

    link.href = "http://www.cnn.com/";
    link.target = "abc";

    Then back to HTML mode and I get:

    Once in the <a href="http://www.nbc.com/" target="abc">far west</a>.

    And here is the problem: It changed the taget attribute but not the href attibute.
    If back in normal mode, I select the word "Once" and click the same custom button I get:

    <a href="http://www.cnn.com/" target="abc">Once</a>&nbsp;in the <a href="http://www.nbc.com/" target="abc">far west</a>.

    Which is the expected bhaviour.
    Can you please tell me what is wrong (with my code or yours) ??
    Many thanks and regards
    José Proença
View Complete Thread