1

私はFirefoxの拡張機能を移植していて、単にWebページのノードにボタンを追加しようとしています. ただし、ページでは何も起こりません。HTMLDOMNode と HTMLElement の間の変換で何かを行う必要があると思います。IE devアドオンを使用して、コンソール内でエラーが発生することさえありません。

私のコード:

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);
    }
4

1 に答える 1

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);
}
于 2012-07-12T09:46:27.223 に答える