如何将事件侦听器添加到用 C# 为 IE BHO 创建的按钮?
在我的 IE BHO 中,我使用以下方法创建一个输入按钮元素:
var button = doc.createElement("input");
button.setAttribute("value", "myButton"); //next line gets an error
button.addEventListener("click", openFunction, false); //openFunction is a function inside of the same class
当我尝试调用 button.addEventListener 时,出现“mshtml.IHTMLElement”不包含“addEventListener”定义的错误。我觉得这很奇怪,因为根据这个网站(http://help.dottoro.com/ljeuqqoq.php< /a>) 我应该是清楚的。
我还看到了这个线程,但对于我想做的事情来说似乎有点矫枉过正,而且我无法让它工作。
In my IE BHO I create a input button element using:
var button = doc.createElement("input");
button.setAttribute("value", "myButton"); //next line gets an error
button.addEventListener("click", openFunction, false); //openFunction is a function inside of the same class
When I try to call button.addEventListener I get a 'mshtml.IHTMLElement' does not contain a definition for 'addEventListener' error. I find this odd because according to this site (http://help.dottoro.com/ljeuqqoq.php) I should be in the clear.
I also saw this thread but it seems like overkill for what I'm trying to do and I can't get it to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于开始工作了。必须使用与我在原始问题中链接的线程类似的方法。
在我的 OnDocumentComplete 方法内部(也在与上面相同的命名空间中[新手的额外信息]):
只是为了获得一个可以单击的按钮,需要做很多工作。在 Firefox 中是一行:O
Finally got it to work. Had to use similar method to the thread I linked in original question.
Inside my OnDocumentComplete method (also in same namespace as above [extra info for novices]):
A lot of work just to get a button to click. In firefox it was one line :O