SBG
SBG

Reputation: 23

IE 11 Error message - Could not complete the operation due to error 800a025e

I am getting the following error message in IE 11 : Could not complete the operation due to error 800a025e.

This error is being thrown when range.select() is called

  function ExtendSelection() {
      var sel;
      if (document.body.createTextRange) { // Internet Explorer
          var range = document.body.createTextRange();
          range.moveStart('character', 0);
          range.collapse(true);
          range.moveStart('character', 29); //causes an exception 
          //range.moveStart('character', 30);//No exception 
          range.moveEnd('character', 177);
          range.select();
          alert(range.text);
      } else {
          alert("Your browser does not support this example!");
      }
  }
<button onclick="ExtendSelection ()">Click to reproduce the error</button>
<a >
    <span>
        <div>
            <select>                         
                <option>CopyTo:</option>
               <option>Headnote</option>
                <option>Synopsis</option>
                <option>Statute</option>
            </select>
        </div>
    </span>
</a>
<a>
    <span>Pages: 8 - 8</span>
</a>
<a>
    <span>nortlaw</span>
</a>
<input>

Replicated for IE 11 browsers only ->JsFiddle example

Upvotes: 2

Views: 3533

Answers (1)

M -
M -

Reputation: 28497

Looking at Microsoft's documentation on TextRange, it seems that the collapse() method doesn't exist. I removed that call, and the error went away.

function ExtendSelection() {
  var sel;
  if (document.body.createTextRange) { // Internet Explorer
      var range = document.body.createTextRange();
      range.moveStart('character', 0);
      // range.collapse(true); <-- IE does not understand this line
      range.moveStart('character', 29); //causes an exception 
      // range.moveStart('character', 30);//No exception 
      range.moveEnd('character', 177);
      range.select();
      alert(range.text);
  } else {
      alert("Your browser does not support this example!");
  }
}

Upvotes: 3

Related Questions