Invalid call 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
       . . .
   }

It works fine, but suddenly gives me

SCRIPT65535: Invalid calling object

I determined that if I check the box, Tools > Compatibility View Settings > [_] Display intranet sites in Compatibility Viewthe aliased function will work fine, but if I clear this field, I will get an error.

What is the reason? What is the specific problem that IE is responding to? Do aliasing functions have such functions? Have there been some changes to the way the "document" object behaves?

+4
source share
2 answers

I just posted this as an answer, but I don't see it. I repeat ...

There is an outstanding answer in this section:

JavaScript aliasing does not work

+2
source

"getElementById()" , , .. , ( Javascript, "this"), ( "document." ).

, , , . , , , .

0

All Articles