Is there a way to dynamically add properties from javasript to object registered in BHO?
i.e
// javascript
window.bho
window.bho.foo = "New property";
throws "Object doesn't support this property or method"
solution must works on .NET 2.0 Framework
// C#
public class ScriptableObject: IScriptableObject
{
WebBrowser webBrowser;
HTMLDocument document;
public ScriptableObject(WebBrowser browser)
{
webBrowser = browser;
document = webBrowser.Document as HTMLDocument;
}
// some methods or properties here
}
public class BHO : IObjectWithSite
{
...
public void OnDownloadComplete()
{
document = webBrowser.Document as HTMLDocument;
window = document.parentWindow as IHTMLWindow2;
IScriptableObject so = new ScriptableObject(webBrowser);
// Adding our custom namespace to JavaScript land.
PropertyInfo myProp = winExpando.AddProperty("bho");
myProp.SetValue(winExpando, so, null);
}
}