What to do when IE moveToElementText throws an Invalid Argument exception

We created a plugin for the Xinha text editor for handling footnotes. You can take a look at: http://www.nicholasbs.com/xinha/examples/Newbie.html

To cope with some problems with the way Webkit and IE handle links at the end of lines (there is no way to use the cursor to exit the link on the same line), we insert an empty element and move the selection to this, than collapse to the right. This works fine in Webkit and Gecko, but for some reason moveToElementText is throwing an Invalid Argument exception. It doesn't matter which element we pass to it, the function seems to be completely broken. However, in other code codes this function works.

To reproduce the error using the link above, click in the main text input area, enter something, then click the yellow page icon using the green plus icon, enter something in the Lightbox dialog box, and click Paste. The following is sample code that causes the problem:

  if (Xinha.is_ie)
  {
    var mysel = editor.getSelection();
    var myrange = doc.body.createTextRange();
    myrange.moveToElementText(newel);
  } else
  {
    editor.selectNodeContents(newel, false);
  }

This code is in svn at: https://svn.openplans.org/svn/xinha_dev/InsertNote

This plugin is built against the Xinha branch available from svn: http://svn.xinha.webfactional.com/branches/new-dialogs

+5
source share
2 answers

, newel dom , DOM. dom , , ( , , DOM , .) moveToElementText .

+5

IE WYSIWYG, - DOM node (,.parentNode) DOM node (, moveToElementText), DOM node .

, DOM node , "" DOM, , node . DOM, IE6 , node "" DOM.

, IE6 "Invalid Argument" try/catch.

+4

All Articles