rem: dump("Setting link around selected text\n"); editorShell.InsertLinkAroundSelection(anchorElement); 
add: try { editorShell.InsertLinkAroundSelection(anchorElement); } catch (e) { dump("Exception occured in InsertElementAtSelection\n"); return true; } }   if (HeadingsIndex > -1 && href[0] == "#") { var name = href.substr(1); var index = GetExistingAnchorIndex(name);   dump("HeadingsIndex="+HeadingsIndex+" SelectIndex="+index+"\n"); if (index > HeadingsIndex) {   var headNode = HNodeList[index - (HeadingsIndex+1)]; var anchorNode = editorShell.editorDocument.createElement("a"); if (anchorNode) { anchorNode.name = name;  editorShell.InsertElement(anchorNode, headNode.parentNode, 0); dump("Anchor node created and inserted under heading\n"); } } else { dump("HREF is a named anchor but is not in the list!\n"); } 
context: function onOK(){  if (ValidateData())  {    if (href.length > 0) {      // Copy attributes to element we are changing or inserting      editorShell.CloneAttributes(anchorElement, globalElement);      // Coalesce into one undo transaction      editorShell.BeginBatchChanges();      // Get text to use for a new link      if (insertNew) {        // Append the link text as the last child node         //   of the anchor node        dump("Creating text node\n");        textNode = editorShell.editorDocument.createTextNode(newLinkText);        if (textNode) {          anchorElement.appendChild(textNode);        }        dump("Inserting\n");        editorShell.InsertElement(anchorElement, false);      } else if (insertLinkAroundSelection) {        // Text was supplied by the selection,        //  so insert a link node as parent of this text        dump("Setting link around selected text\n");        editorShell.InsertLinkAroundSelection(anchorElement);      }      editorShell.EndBatchChanges();    } else if (!insertNew) {      // We already had a link, but empty HREF means remove it      editorShell.RemoveTextProperty("a", "");    }    return true;  }  return false;}
meta: 10234	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/10234/711c0f72c9655c2558d43bb716847f1a294b8372/EdLinkProps.js/clean/editor/ui/dialogs/content/EdLinkProps.js