Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 刷新Web浏览器内容_C#_Jquery_Webbrowser Control - Fatal编程技术网

C# 刷新Web浏览器内容

C# 刷新Web浏览器内容,c#,jquery,webbrowser-control,C#,Jquery,Webbrowser Control,我有带WebBrowser控件的windows窗体应用程序。我已经完成了修改文档内部html的事件处理程序: public void DocumentCompleted(object sender, EventArgs e) { var browser = (sender as WebBrowser); if (browser != null && browser.Document != null && browser.Document.Body

我有带WebBrowser控件的windows窗体应用程序。我已经完成了修改文档内部html的事件处理程序:

public void DocumentCompleted(object sender, EventArgs e)
{
    var browser = (sender as WebBrowser);
    if (browser != null && browser.Document != null && browser.Document.Body != null)
    {
        var documentHtml = browser.Document.Body.InnerHtml;
        browser.Document.Body.InnerHtml = Replacer.Replace(documentHtml);
    }
}
我还有另一种方法:

public void Inject(string element, string contents)
{
    var browser = webBrowser;
    if (browser != null && browser.Document != null && browser.Document.Body != null)
    {
        HtmlElement htmlElement = browser.Document.GetElementById(element);
        if (htmlElement != null)
        {
            htmlElement.InnerHtml = contents;
        }
    }
}
我使用此方法将html页面(变量“contents”)插入现有页面中。它类似于jquery的“加载”:
$(“#divisionId”).load(“路径到html页面”)
在注入的html页面中,有一些javascript代码:

<script type="text/javascript">
    $(function () {
        // some code here
    });
</script>

$(函数(){
//这里有一些代码
});
执行
htmlElement.InnerHtml=contents时仅加载html标记,但未执行文档就绪功能。如何手动调用此函数或使WebBrowser刷新其修改内容以执行此函数