Search code examples
javascriptinternet-explorereventsdom-events

window.Event vs window.event


For some reason when fired through C# code by using the IHTMLElement2.focus() method call, an onfocus event will not set window.event (which will become null), instead some other object window.Event will get set with the event information. Is there a reason for this? I am using ShDocVw interface for InternetExplorer and this is the first time I have seen this issue.


Solution

  • Sounds like a typical microsoft bug. They often have a problem with case sensitivity since it has been onverlooked as a distinction since day one of the OS.

    I would suggest maybe looking into this kb article http://msdn.microsoft.com/en-us/library/aa703985(v=vs.85).aspx specifically the tabindex hooha which sounds like a joke, but what else would you expect.

    Then I would suggest trying the 4th variant form of IHTMLElement particularly the onfocusin event as an alternative to onfocus.

    But ultimately since you control the environment via the shdocvw object - I'd just map the window.Event object to the window.event object in your onfocus handler - one line of code never hurt no one - except for when that one line of code hurts someone with a stack overflow, buffer overrun or Out of Memory exception of course :D