Failed to call a BHO method from Javascript in IE9
I am trying to call a BHO object method from a javascript function (the javascript is injected by the BHO using IHTMLWindow2 execScript).
function foo()
{
IEBHO.Do开发者_如何学GoSomething();
}
The IEBHO is a BHO object and loaded in IE9 already.
And the "DoSomething" interface/method is declared in IDL file of BHO project as:
[id(1), helpstring("method DoSomething")] HRESULT DoSomething();
This approach works fine with IE7 and IE8 perfectly. The method/interface "DoSomething" gets called from the javascript function successfully.
However in IE9, it seems to fail always. The javascript seems to fail to find the IEBHO object in its namespace, which results failure of calling the "DoSomething" method.
I even used the IE7/IE8 Document Mode inside IE9 and they all works fine, but as soon as it is set to the default IE9 document mode, it fails.
Is this a BUG in IE9? or there is a new way do accessing the BHO method?
Please help...
Best regards,
Frank
For firsy time, check that BHO is enabled in you IE9
Extensibility
In Internet Explorer 9, the extensibility mechanisms for Browser Helper Objects (BHOs) and toolbars remain the same. Not loading BHOs or toolbars improves startup time, but limits the ability of developers to augment the user experience through these extensibility mechanisms.
via http://en.wikipedia.org/wiki/Internet_Explorer_9
You can create an extension by simply creating keys in registry, with a javascript file.
In this javascript file, you may call your BHO function DoSomething(). When you click the button at command bar, the BHO function will be called.
精彩评论