问题描述
我试图操纵在WPF web浏览器控制一个请求的文档。我已经设法它来调用加载文件的JavaScript,但我不能够改变显示HTML的code。在控件本身。
I am trying to manipulate a requested document in the WPF WebBrowser-control. I already managed it to invoke JavaScript on loaded document, but I am not able to change the shown HTML-code in the control itself.
我的(非常简化)$ C $在OnNavigating处理程序C相类似这样的:
My (very simplified) code in the OnNavigating-Handler looks like this:
mshtml.HTMLDocument doc = (mshtml.HTMLDocument)View.browser.Document;
HTMLTableClass table = doc.getElementById("someTable") as HTMLTableClass;
if (table != null)
{
table.appendChild((IHTMLDOMNode)(doc.createElement("<tr>") as IHTMLElement));
}
doc.close();
该-element不会被追加到在控件中显示的文档。
任何提示都非常AP preciated!
The -element doesn't get appended to displayed document in the control.Any hints are very appreciated!
推荐答案
我终于得到它。其唯一可能通过增加行和细胞,我想避免在首位改变表的内容。我的方法是直接更改-tag,其中没有工作的内容。
I finally got it. Its only possible to change the content of the table by adding rows and cells which i wanted to avoid in first place. My approach was to directly change the content of the -tag, which didnt work.
mshtml.IHTMLTableRow row = table.IHTMLTable_insertRow(-1) as mshtml.IHTMLTableRow;
mshtml.IHTMLElement c = (mshtml.IHTMLElement)row.insertCell(0);
c.innerText = "some";
mshtml.IHTMLElement c1 = (mshtml.IHTMLElement)row.insertCell(1);
c1.innerText = "text";
这篇关于使用HTMLDocument的操纵HTML并显示在web浏览器控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!