我正在尝试注入一些 javascript 代码以防止 javascript 错误弹出,但我在 WPF 中找不到HTMLDocument
和:IHTMLScriptElement
var doc = browser.Document as HTMLDocument;
if (doc != null)
{
//Create the sctipt element
var scriptErrorSuppressed = (IHTMLScriptElement)doc.createElement("SCRIPT");
scriptErrorSuppressed.type = "text/javascript";
scriptErrorSuppressed.text = m_disableScriptError;
//Inject it to the head of the page
IHTMLElementCollection nodes = doc.getElementsByTagName("head");
foreach (IHTMLElement elem in nodes)
{
var head = (HTMLHeadElement)elem;
head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
}
}