webview相关
1,错误提示this.webBrowser1.ScriptErrorsSuppressed = true;
2,改变目票
private void changeTarget()
{
foreach (HtmlElement archor in this.webBrowser1.Document.Links)
{
archor.SetAttribute("target", "_self");
}
//将所有的FORM的提交目标,指向本窗体
foreach (HtmlElement form in this.webBrowser1.Document.Forms)
{
form.SetAttribute("target", "_self");
}
}
3,加载完成
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete)
{
return;
}
else
{
changeTarget();
mWebViewLoadComplete = true;
}
}
4,获取控件
1,id
HtmlElement pswElement = webBrowser1.Document.GetElementById("psw");
2,tag
HtmlElementCollection trCollection = recordListElement.GetElementsByTagName("tr");
3,设置value
pswElement.SetAttribute("value", textBoxPassword.Text);
4,执行点击
loginBtn.InvokeMember("click");
5,获取class(注意足然写的是class="",但获取时还是要className)
String className = iPage.GetAttribute("className");
页:
[1]