我正在移植firefox扩展,只是尝试将按钮附加到网页上的节点。但是页面上没有任何内容。我相信它必须对HTMLDOMNode和HTMLElement之间的转换做些什么。我甚至没有在使用IE开发添加的控制台内部出现任何错误。
我的代码:
public void OnDocumentComplete(object pDisp, ref object URL)
{
HTMLDocument document = (HTMLDocument)webBrowser.Document;
var fblike = document.getElementById("LikePluginPagelet");
var button = document.createElement("input");
button.setAttribute("value", "myButton");
button.setAttribute("onClick", "doSomething()");
((IHTMLDOMNode)fblike).appendChild((IHTMLDOMNode)button);
}
答案 0 :(得分:2)
你需要制作fblike动态。
public void OnDocumentComplete(object pDisp, ref object URL)
{
HTMLDocument document = (HTMLDocument)webBrowser.Document;
var fblike = document.getElementById("LikePluginPagelet");
var button = document.createElement("input");
button.setAttribute("value", "myButton");
button.setAttribute("onClick", "doSomething()");
dynamic fbLike = fblike
fbLike.appendChild((IHTMLDOMNode)button);
}