我正在尝试在Internet Explorer扩展中生成合成Javascript事件,并且我无法获取fromElement属性.这是我的代码的摘录:
MsHtml.IHTMLDocument4 doc4 = ... // the document object Object o = null; MsHtml.IHTMLEventObj2 eObj = (MsHtml.IHTMLEventObj2)doc4.CreateEventObject(ref o); // string that specifies the from element, e.g. "document.getElementById('id1')": string locator = ... object from = doc4.Script.GetType().InvokeMember("eval", BindingFlags.InvokeMethod, null, doc4.Script, new object[] { locator }); // from now holds a ref to an object that implements the IHTMLElement interface eObj.fromElement = from; IHTMLElement el = eObj.fromElement; // el == null
我在这做错了什么?eObj.fromElement应该等于from,但它似乎没有设置.