Search code examples
javascriptinternet-explorer-10

Invalid Calling Object, and Compatibility


In Internet Explorer 10, I have the following:

  /* 
   *   Alias document.getElementById(), to reduce typing, improve
   *   readability and speed up access to the function.
   */
   var getElmById = document.getElementById;

   function . . . (ctlID) {
       var ctrl = getElmById(ctlID);  // <————<<< error raised here
       . . .
   }

This has been working fine, but suddenly is giving me

SCRIPT65535: Invalid calling object

I have determined that if I check the box, Tools > Compatibility View Settings > [_] Display intranet sites in Compatibility View, the aliased function runs just fine, but if I clear that box, I get the error.

What is the reason? What is the specific issue that IE is responding to? Has aliasing functions like that been eliminated? Has there been some change to the way the 'document' object behaves?


Solution

  • I just posted this as an answer, but I don't see it. Trying again...

    This topic has an outstanding answer:

    JavaScript function aliasing doesn't seem to work