Could not complete the operation due to error 800a

2019-04-06 15:00发布

问题:

What does this error mean in IE10/11:

Error: Could not complete the operation due to error 800a025e. 

And how would I debug it?

It says its this line:

this.nativeSelection.removeAllRanges();

https://code.google.com/p/rangy/source/browse/trunk/src/js/core/wrappedselection.js#416

See it in action here: http://panmedia.github.io/raptor-editor/tests/cases/selection/selection-expand.html

回答1:

I had this error coming up recently, I fixed it with the following chceck:

var sel = window.document.getSelection();
if (sel.rangeCount > 0 && sel.getRangeAt(0).getClientRects().length > 0) {
    sel.removeAllRanges();
}


回答2:

I got this error when trying to window.getSelection().removeAllRanges(); and there was no selection. One workaround is to check if there is a selection first:

if (window.getSelection().getRangeAt(0).getClientRects.length > 0) {
    window.getSelection().removeAllRanges();
}


回答3:

All the error 80020101 means is that there was an error, of some sort, while evaluating JavaScript. If you load that JavaScript via Ajax, the evaluation process is particularly strict.

Could not complete the operation due to error 80020101. IE