Internet Explorer may not return the same DISPID for the same property

Warning

The retired, out-of-support Internet Explorer 11 desktop application has been permanently disabled through a Microsoft Edge update on certain versions of Windows 10. For more information, see Internet Explorer 11 desktop app retirement FAQ.

This article provides information about resolving Internet Explorer may not return the same DISPID with the same property.

Original product version:   Internet Explorer 9 and later versions
Original KB number:   2855169

Symptoms

Imagine a scenario where an application uses a binary behavior to define a custom property (let's call it MyProp). The binary behavior is attached to a DOM element running in Internet Explorer 9 standards mode or above. Customer may also be running other binary behaviors, ActiveX controls, or other browser add-ins, which call IDispatch::GetIDsOfNames to resolve the DISPID for the MyProp property. In certain situation, Internet Explorer does not always return the same DISPID for every GetIDsOfNames call when running in Internet Explorer 9 standards mode or above.

Resolution

One way to work around this problem is to access the custom property MyProp first using JavaScript before calling IDispatch::GetIDsOfNames from a browser add-in. An example of this is to use the following function in the web page's body onload event:

function foo()
{
    var a = document.getElementById("myelem");  // myelem is the id of the element which has the attached binary behavior
    if (a.myprop == null)  // myprop is the property in question
        //alert("null");
        ;
    else
        //alert("not null");
        ;
}